可以按多行排序吗?
我希望我的用户按last_activity排序,但与此同时,我希望带有图片的用户出现在没有
的用户之前这样的事情:
SELECT some_cols
FROM `prefix_users`
WHERE (some conditions)
ORDER BY last_activity, pic_set DESC;
答案 0 :(得分:130)
SELECT some_cols
FROM prefix_users
WHERE (some conditions)
ORDER BY pic_set DESC, last_activity;
答案 1 :(得分:13)
按照图片排序,然后按活动排序:
SELECT some_cols
FROM `prefix_users`
WHERE (some conditions)
ORDER BY pic_set, last_activity DESC;
答案 2 :(得分:0)
SELECT id, user_id, video_name
FROM sa_created_videos
ORDER BY LENGTH(id) ASC, LENGTH(user_id) DESC