MySQL 中的 UNION 和 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";
mysql_error()
返回:“ORDER BY 和 UNION 的使用不当”。
You should see what I'm trying to do here but it's not working
$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";
mysql_error()
returns: "improper usage of ORDER BY and UNION".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
查看对我的答案的评论关于相关问题。
或者查阅详细手册。
Try:
See the comments to my answer on the related question.
Or consult the fine manual.
要将 ORDER BY 或 LIMIT 应用于单个 SELECT,请将子句放在包含 SELECT 的括号内:
To apply ORDER BY or LIMIT to an individual SELECT, place the clause inside the parentheses that enclose the SELECT: