MySQL中的UNION和ORDER BY问题

Tul*_*les 3 mysql sql union sql-order-by

你应该看看我在这里想做什么,但它没有用

$getquery = "SELECT * 
FROM highscore 
WHERE score >= '$score'
ORDER BY score ASC
LIMIT 6

UNION

SELECT * 
FROM highscore 
WHERE score < '$score'
ORDER BY score DESC
LIMIT 5";
Run Code Online (Sandbox Code Playgroud)

mysql_error() 返回:"ORDER BY和UNION的使用不当".

Erw*_*ter 9

尝试:

$getquery = "(SELECT * 
FROM highscore 
WHERE score >= '$score'
ORDER BY score ASC
LIMIT 6)

UNION ALL -- guaranteed to be beneficial in this case as Johan commented

(SELECT * 
FROM highscore 
WHERE score < '$score'
ORDER BY score DESC
LIMIT 5)";
Run Code Online (Sandbox Code Playgroud)

请参阅我对相关问题的答案评论.
或者查阅精细手册.