SELECT * FROM att_record2 WHERE DATE(row_datentime)=DATE_SUB(CURDATE(), INTERVAL 1 DAY)
AND out_datentime="0000-00-00 00:00:00" AND in_datentime!="0000-00-00 00:00:00"
我想获取今天和昨天的数据 我只批准昨天的唯一演出,但我想今天和昨天都请帮助我
答案 0 :(得分:1)
好的,您可以获得昨天和今天的以下功能:
mysql> select curdate() as today;
+------------+
| today |
+------------+
| 2019-06-12 |
+------------+
1 row in set (0.00 sec)
mysql> select curdate() - interval 1 day as yesterday;
+------------+
| yesterday |
+------------+
| 2019-06-11 |
+------------+
1 row in set (0.00 sec)
mysql> select curdate() + interval 1 day as tomorrow;
+------------+
| tomorrow |
+------------+
| 2019-06-13 |
+------------+
1 row in set (0.00 sec)
因此,完整的SQL:
select
*
from
att_record2
where
date(row_datentime) >= curdate() - interval 1 day
and date(row_datentime) <= curdate()
and out_datentime='0000-00-00 00:00:00'
and in_datentime!='0000-00-00 00:00:00'
答案 1 :(得分:0)
使用> =和<=如下
SELECT * FROM att_record2 WHERE row_datentime >= NOW() - INTERVAL 1 DAY AND row_datentime <= NOW() AND out_datentime="0000-00-00 00:00:00" AND in_datentime!="0000-00-00 00:00:00"