且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从mysql表中获取前一天的记录?

更新时间:2023-01-29 20:35:40

使用SQL完成后非常简单,只需添加条件

Fairly simple when done with SQL, just add the condition

WHERE creationDate BETWEEN CURDATE() - INTERVAL 1 DAY AND CURDATE()

无需转换creationDate,因为它已经是一个日期:).而且我相信这将是最快的检查方法(如果您查看大量数据集,这将很重要).

There is no need to convert creationDate as it is already a date :). And i belive that this will be the fastest way to check it (which will matter if you go over large data sets).