我想从用户中选择所有,然后显示所有输出ASC,但我想显示那些在顶级ASC上具有更高COUNT的那些。这是代码:
$sql = "SELECT *
FROM user
ORDER BY user_id ASC,
(SELECT *
FROM user
WHERE count > 40
ORDER BY hits DESC) DESC";
基本上选择所有用户,然后显示ORDER BY user_id ASC,但我也想把ORDER放在那些排名第一的用户之上。我从这个sql中遗漏了什么?
答案 0 :(得分:0)
试试这段代码:
SELECT * FROM user WHERE count > 40 ORDER BY count DESC, user_id ASC