SELECT * FROM `user`
WHERE name !='' AND `date_created` BETWEEN DATE_SUB( CURDATE( ) ,INTERVAL 3 Day )
AND DATE_SUB( CURDATE( ) ,INTERVAL 0 Day )
ORDER BY `date` ASC
上述查询从今天开始记录3day。
但我今天需要3day记录,这意味着明天,后天等等。
date_created是mysql日期格式。
答案 0 :(得分:6)
SELECT * FROM `user`
WHERE name !=''
AND `date_created` BETWEEN curdate() and curdate() + interval 3 day
ORDER BY `date`
答案 1 :(得分:0)
我创建了这将返回前3天的记录
select * from events where DATEOFEVENT IN (select date(curdate()-3 ))