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的使用不当".
尝试:
$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)