我收到此错误:
1064-您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册以使用正确的语法 靠近'=>“ 2018-08-14” AND createDate = <“ 2018-08-28”排序方式 createDate DESC LIMIT 0,在第1行
当我运行此查询时:
SELECT * FROM offer_request WHERE createDate => "2018-08-14" AND createDate =< "2018-08-28" ORDER BY createDate DESC LIMIT 0, 15
createDate是日期时间字段。即:2018-07-19 12:53:59
答案 0 :(得分:0)
使用日期函数转换createDate:
SELECT * FROM offer_request WHERE date(createDate) >= '2018-08-14' AND date(createDate) <= '2018-08-28' ORDER BY createDate DESC LIMIT 0, 15
答案 1 :(得分:0)
您的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
答案 2 :(得分:0)
尝试这种最简单有效的方法:)
SELECT * FROM offer_request WHERE createDate BETWEEN "2018-08-14" AND "2018-08-28" ORDER BY createDate DESC LIMIT 0, 15