简体   繁体   English

MySQL中的ORDER BY日期,收到错误

[英]ORDER BY date in MySQL, receiving error

I have a SQL table with a date value (name is date and type is datetime). 我有一个带有日期值的SQL表(名称是日期,类型是日期时间)。 I need to order my output by date, but I recive a error message: 我需要按日期订购我的输出,但我收到一条错误消息:

Error: You have an error in your SQL syntax; 错误:SQL语法中有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY date ASC' at line 1 检查与MySQL服务器版本对应的手册,以便在第1行的“ORDER BY date ASC”附近使用正确的语法

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";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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