时间:2021-07-01 10:21:17 帮助过:5人阅读
SELECT * FROM user ORDER BY time WHERE time >= 1111-11-11 10:10:10
会报错,而SELECT * FROM user ORDER BY time
和SELECT * FROM user WHERE time >= 1111-11-11 10:10:10
都正常,这是为什么?以前都是用thinkphp封装的类操作数据库,最近采用原生mysql写一下子就卡壳了。
mysql php中SELECT * FROM user ORDER BY time WHERE time >= 1111-11-11 10:10:10
会报错,而SELECT * FROM user ORDER BY time
和SELECT * FROM user WHERE time >= 1111-11-11 10:10:10
都正常,这是为什么?以前都是用thinkphp封装的类操作数据库,最近采用原生mysql写一下子就卡壳了。
逻辑顺序错了阿,怎么可能先排序再条件查询呢?先条件查询然后再ORDER BY
自己用thinkphp生成最后的语句看了下是关键字顺序的问题,调整后如下SELECT * FROM
userWHERE(
time>= '2014-11-10 10:10:10') ORDER BY time
运行成功了