我想执行以下命令
SELECT * FROM `auktionen` LIMIT 0, 5 ORDER BY createdat DESC
告诉我我有一个SQL语法错误。我followed this questions answer。
每当我删除LIMIT或ORDER BY语句时,它将再次执行:
SELECT * FROM `auktionen` ORDER BY createdat DESC
SELECT * FROM `auktionen` LIMIT 0, 5
那我究竟做错了什么?
答案 0 :(得分:5)
gg wp。感谢您的提示,如果您希望它被接受,请添加为答案 - 4ndro1d
根据OP的要求。
LIMIT排在最后。这是一个糟糕的答案https://stackoverflow.com/a/26041483/1415724。
请参阅SELECT自己的手册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]]