我有一个sql语句,它将external
作为最后一个,但我也希望按名称对结果的其余部分进行排序。是否可以使用两个ORDER BY
?
SELECT `id`
FROM `user`
WHERE `parent` = %d AND `isFolder` = 1
ORDER BY CASE WHEN name = \'External\' THEN 2 ELSE 1 END
答案 0 :(得分:0)
根据要求,我的评论作为答案!
只需将name
列添加到ORDER BY
列表中:
SELECT `id`
FROM `user`
WHERE `parent` = %d AND `isFolder` = 1
ORDER BY CASE WHEN name = \'External\' THEN 2 ELSE 1 END, name