本文介绍了MySql结合了LIMIT和ORDER BY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要执行以下命令
SELECT * FROM `auktionen` LIMIT 0, 5 ORDER BY createdat DESC
这告诉我我有一个SQL语法错误.我遵循了这个问题的答案.
which tells me I have an SQL syntax error. I followed this questions answer.
无论何时删除LIMIT或ORDER BY语句,它都会再次执行:
Whenever I delete either the LIMIT or the ORDER BY statement it will execute again:
SELECT * FROM `auktionen` ORDER BY createdat DESC
SELECT * FROM `auktionen` LIMIT 0, 5
那我到底在做什么错?
推荐答案
根据OP的要求.
LIMIT倒数第二个. https://stackoverflow.com/a/26041483/1415724 这是一个错误的答案.
LIMIT goes last. That was a bad answer https://stackoverflow.com/a/26041483/1415724.
自行咨询有关SELECT的手册 http://dev. mysql.com/doc/refman/5.7/en/select.html
Consult the manual on SELECT for yourself http://dev.mysql.com/doc/refman/5.7/en/select.html
SELECT
[ALL | DISTINCT | DISTINCTROW ]
[HIGH_PRIORITY]
[MAX_STATEMENT_TIME = N]
[STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
select_expr [, select_expr ...]
[FROM table_references
[PARTITION partition_list]
[WHERE where_condition]
[GROUP BY {col_name | expr | position}
[ASC | DESC], ... [WITH ROLLUP]]
[HAVING where_condition]
[ORDER BY {col_name | expr | position}
[ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
[PROCEDURE procedure_name(argument_list)]
[INTO OUTFILE 'file_name'
[CHARACTER SET charset_name]
export_options
| INTO DUMPFILE 'file_name'
| INTO var_name [, var_name]]
[FOR UPDATE | LOCK IN SHARE MODE]]
这篇关于MySql结合了LIMIT和ORDER BY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!