对datetime字段运行select查询时出错

deikduxw  于 2021-06-23  发布在  Mysql
关注(0)|答案(3)|浏览(302)

我有个错误:
1064-您的sql语法有错误;请查看与您的mysql服务器版本对应的手册,以获取在第1行“=>”2018-08-14“和createdate=<”2018-08-28“order by createdate desc limit 0”附近使用的正确语法
运行此查询时:

SELECT * FROM offer_request WHERE createDate => "2018-08-14" AND createDate =< "2018-08-28" ORDER BY createDate DESC LIMIT 0, 15

createdate是datetime字段。i、 电子:2018-07-19 12:53:59

olmpazwi

olmpazwi1#

您的sql查询有错误,必须这样使用,并尝试对datetime字段使用date()函数

SELECT * FROM offer_request WHERE date(createDate) >= '2018-08-14' AND date(createDate) =< '2018-08-28' ORDER BY createDate DESC LIMIT 0, 15
h43kikqp

h43kikqp2#

使用日期函数转换createdate:

SELECT * FROM offer_request WHERE date(createDate) >= '2018-08-14' AND date(createDate) <= '2018-08-28' ORDER BY createDate DESC LIMIT 0, 15
7gcisfzg

7gcisfzg3#

试试这个最简单有效的方法:)

SELECT * FROM offer_request WHERE createDate BETWEEN "2018-08-14" AND "2018-08-28" ORDER BY createDate DESC LIMIT 0, 15

相关问题