A mysql statement

Source: Internet
Author: User
In mysqlphp, SELECT * FROMuserORDERBYtimeWHEREtime & amp; gt; 1111-11-, an error is reported, while SELECT * FROMuserORDERBYtime and SELECT * FROMuserWHEREtime & amp; gt; 1111-11-are normal, why... mysql php
SELECT * FROM user ORDER BY time WHERE time >= 1111-11-11 10:10:10An error is reported.
SELECT * FROM user ORDER BY timeAnd SELECT * FROM user WHERE time >= 1111-11-11 10:10:10All are normal. Why? Previously, I used to operate databases using thinkphp encapsulation. Recently I used Native mysql to write the database, and the database became stuck.

Reply content:

Mysql php
SELECT * FROM user ORDER BY time WHERE time >= 1111-11-11 10:10:10An error is reported.
SELECT * FROM user ORDER BY timeAndSELECT * FROM user WHERE time >= 1111-11-11 10:10:10All are normal. Why? Previously, I used to operate databases using thinkphp encapsulation. Recently I used Native mysql to write the database, and the database became stuck.

The logic order is wrong. How can I sort the data before conditional query? First query conditions and then ORDER

I used thinkphp to generate the final statement and checked the keyword order. The adjusted statement is as follows:SELECT * FROMUserWHERE(Time>= '2014-11-10 10:10:10') ORDER BY timeRunning successfully

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.