简体   繁体   English

SQL 与另一个条件语句之间的日期不起作用

[英]SQL Date between and another condition statement not working

Here is two SQL Query when executing this SQL its work fine.这是执行此 SQL 时的两个 SQL 查询,其工作正常。

SELECT * 
  FROM xyz 
 WHERE file_play_start_date BETWEEN '2011-07-01 06:15:00' 
                                AND '2011-07-08 06:30:00'

...but when adding another condition then its not working. ...但是当添加另一个条件时,它不起作用。 ei:returning no result tho there is result to show in this condition. ei:不返回任何结果,但在这种情况下有结果要显示。

SELECT * 
  FROM xyz 
 WHERE calender_id = 3 
   AND file_play_start_date BETWEEN '2011-07-01 06:15:00' 
                                AND '2011-07-08 06:30:00'

Can any one tell me why its happening?谁能告诉我为什么会这样?

Because there are no records with calendar_id of 3 and the file_play_start_date between those two values.因为在这两个值之间没有calendar_id为 3 和file_play_start_date的记录。

select count(*) from reqcat.tpa_log where pa_status_cd='BAD' and row_update_time BETWEEN '2018-01-01' AND '2018-02-28';

Its not working.它不工作。 But when I do the但是当我做

count * with pa_status_cd='BAD' and row_update_time BETWEEN '2018-01-01' AND '2018-02-28'

seperately it works.单独它工作。

There are no rows in xyz where calender_id = 3 and file_play_start_date between '2011-07-01 06:15:00' and '2011-07-08 06:30:00'. xyz 中没有行,其中 calender_id = 3 和 file_play_start_date 在 '2011-07-01 06:15:00' 和 '2011-07-08 06:30:00' 之间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM