我需要获取等于和小于2012-12-28的所有记录,为此我使用了波纹管式查询,booking_time是DATETIME字段,并且有小于2012-12-28的记录,但它返回零行。有人有主意吗?
SELECT * FROM ctx_bookings WHERE DATE(booking_time)<=2012-12-28 ORDER BY id ASC
表格已归档
+---------------------+ | booking_time | +---------------------+ | 2012-12-20 03:10:09 | | 2012-12-25 02:10:04 | +---------------------+
请任何人知道为什么会这样吗?
用单引号括起来的值,肯定会起作用
SELECT * FROM ctx_bookings WHERE DATE(booking_time) <= '2012-12-28' ORDER BY id ASC