Sql day, two days before and so before time field data acquisition in accordance with

Original link: http://www.cnblogs.com/yanchaohui/p/11008826.html
// get the day before 
SELECT * FROM table WHERE DATE (time field) = DATE_SUB (CURDATE (), INTERVAL 1 DAY)
// get two days before ,,,, and so 
SELECT * FROM table WHERE DATE (time field) = DATE_SUB (CURDATE (), INTERVAL 2 DAY)
// get the day 
SELECT * FROM table WHERE DATE (time field) = DATE_SUB (CURDATE (), INTERVAL 0 DAY)

 

Reproduced in: https: //www.cnblogs.com/yanchaohui/p/11008826.html

Guess you like

Origin blog.csdn.net/weixin_30338497/article/details/95160588