[英]Get today and yesterday data from mysql
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"
I want to get data from today and yesterday My approch its only show yesterday record only but i want both today and yesterday please help me 我想获取今天和昨天的数据我的申请仅显示了昨天的记录,但是我希望今天和昨天都可以帮助我
OK, you can get yesterday and today as below functions: 好的,您可以获得昨天和今天的以下功能:
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)
So the complete SQL: 所以完整的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'
使用> =和<=如下
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"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.