我在表中有列,类型为时间戳,我在数据库中有2条记录,一条值为"2014-07-12 23:10:15",另一条值为"2013-06-01 01:10:12"
现在查询表,但我返回空结果:
SELECT comments.* FROM tbl_product_comments as comments WHERE DATE(comments.created_date) BETWEEN 2010-06-01 AND 2014-07-13
也是这样,但还是得到空结果
SELECT comments.* FROM tbl_product_comments as comments WHERE DATE(comments.created_date) > 2010-06-01 AND DATE(comments.created_date) < 2014-07-13
可以有人告诉我,为什么我没有得到结果,什么将是正确的查询。
谢谢. .
将日期用引号括起来。
BETWEEN '2010-06-01' AND '2014-07-13'
您的原始代码被解析为算术表达式。
2010-06-01 = 2003
2014-07-13 = 1994
的例子。返回数据:
select * from tab where 2009 between 2010-01-01 and 2014-01-01
对
select * from tab where 2009 between 2008 and 2012