简体   繁体   中英

ORDER BY date in MySQL, receiving error

I have a SQL table with a date value (name is date and type is datetime). I need to order my output by date, but I recive a error message:

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY date ASC' at line 1

Here's my code:

$sql = "SELECT * FROM Posts1 LIMIT 10 ORDER BY date ASC";

你需要像这样把'LIMIT'放在最后

$sql = "SELECT * FROM Posts1 ORDER BY `date` ASC LIMIT 10";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM