Mysql日期功能不起作用 [英] Mysql date function not working for less than
本文介绍了Mysql日期功能不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
的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
I need to get all records those equal and less than 2012-12-28 i used bellow query for this, booking_time is DATETIME field, and there are records less than 2012-12-28 but it returns zero rows. does anyone has idea ?
SELECT * FROM ctx_bookings WHERE DATE(booking_time)<=2012-12-28 ORDER BY id ASC
Table filed
+---------------------+
| booking_time |
+---------------------+
| 2012-12-20 03:10:09 |
| 2012-12-25 02:10:04 |
+---------------------+
Please anybody know why is this happening ?
解决方案
wrap the value with single quote and surely it will work
SELECT *
FROM ctx_bookings
WHERE DATE(booking_time) <= '2012-12-28'
ORDER BY id ASC
这篇关于Mysql日期功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文