Home  >  Article  >  Backend Development  >  一条mysql语句

一条mysql语句

WBOY
WBOYOriginal
2016-06-06 20:37:49998browse

mysql php中
SELECT * FROM user ORDER BY time WHERE time >= 1111-11-11 10:10:10会报错,而
SELECT * FROM user ORDER BY timeSELECT * 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 timeSELECT * FROM user WHERE time >= 1111-11-11 10:10:10都正常,这是为什么?以前都是用thinkphp封装的类操作数据库,最近采用原生mysql写一下子就卡壳了。

逻辑顺序错了阿,怎么可能先排序再条件查询呢?先条件查询然后再ORDER BY

自己用thinkphp生成最后的语句看了下是关键字顺序的问题,调整后如下SELECT * FROMuserWHERE(time>= '2014-11-10 10:10:10') ORDER BY time运行成功了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn