Mysql时间怎样查寻 Mysql时间查寻编码实例

查寻当今时间
SELECT CURRENT_DATE();
SELECT CURDATE();
查寻当今时间和時间
SELECT NOW();
查寻今日的数据信息
SELECT * FROM `表名` WHERE TO_DAYS(NOW()) = TO_DAYS(`字段名`);
SELECT * FROM `表名` WHERE TO_DAYS(NOW()) - TO_DAYS(`字段名`) = 0;
查寻昨日的数据信息
SELECT * FROM ``表名`` WHERE TO_DAYS(`字段名`) = TO_DAYS(NOW()) -1;
SELECT * FROM ``表名`` WHERE TO_DAYS(`字段名`) - TO_DAYS(NOW()) = -1;
SELECT * FROM ``表名`` WHERE TO_DAYS(NOW()) = TO_DAYS(`字段名`) +1;
SELECT * FROM ``表名`` WHERE TO_DAYS(NOW()) - TO_DAYS(`字段名`) = 1;
查寻近期七天的数据信息
SELECT * FROM `表名` WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) 

      

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://zzjzptp.cn/ganhuo/3838.html