将DATE列与特定日期进行比较的MySql查询不会将特定结果返回到日期,因此intead将返回所有条目

时间:2016-07-28 07:07:43

标签: php mysql sql database

我在mysql表上有以下查询

   select * from scheduled_work where id_location = {$location} and scheduled_date = '{$date}' and is_active

scheduled_date是列类型日期(2016-07-27)

当我运行查询时,我不会只获得特定日期的结果,而是获得表格中所有条目的结果

表格结构

#   Name    Type    Collation   Attributes  Null    Default Extra   Action
1   id_scheduled_work   int(11)         No  None    AUTO_INCREMENT  Change Change   Drop Drop   

More

2   id_schedule_hours   int(11)         No  None        Change Change   Drop Drop   

More

3   id_truck    int(11)         No  None        Change Change   Drop Drop   

More

4   id_driver   int(11)         No  None        Change Change   Drop Drop   

More

5   scheduled_date  date            No  None        Change Change   Drop Drop   

More

6   id_location int(11)         No  None        Change Change   Drop Drop   

More

7   id_user int(11)         No  None        Change Change   Drop Drop   

More

8   created_at  timestamp           No  CURRENT_TIMESTAMP       Change Change   Drop Drop   

More

9   updated_at  timestamp       on update CURRENT_TIMESTAMP No  0000-00-00 00:00:00 ON UPDATE CURRENT_TIMESTAMP Change Change   Drop Drop   

More

10  is_active   tinyint(1)          No  1

和继承人样本条目

     Full texts     id_scheduled_work   id_schedule_hours   id_truck    id_driver   scheduled_date  id_location     id_user     created_at  updated_at  is_active
Edit Edit   Copy Copy   Delete Delete   1   1   1   1   2016-07-22  1   1   2016-07-22 17:44:40     0000-00-00 00:00:00     1
Edit Edit   Copy Copy   Delete Delete   2   2   1   1   2016-07-22  1   1   2016-07-22 18:02:20     0000-00-00 00:00:00     1
Edit Edit   Copy Copy   Delete Delete   3   1   1   1   2016-07-27  1   1   2016-07-28 01:49:53     2016-07-28 01:52:08     1
Edit Edit   Copy Copy   Delete Delete   4   1   3   1   2016-07-27  1   1   2016-07-28 01:49:53     2016-07-28 01:52:19     1

0 个答案:

没有答案