Posts Tagged sql

sql基于时间查询(select)

返回所有posts表中,2009年5月13号到16号的记录。created是posts表的timestamp。

select * from posts where date(created) bettwen date(2009-05-13) and date(2009-05-16)

除了date(),还有year(),month(),day()可以使用。year(2009-05-13) 返回2009,month(2009-05-13)返回05,day(2009-05-13)返回13

Happy Coding…

2 Comments