mysql按多个项目查询顺序

mysql按多个项目查询顺序

本文介绍了mysql按多个项目查询顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以按多行订购?

is is possible to order by multiple rows?

我希望我的用户按last_activity进行排序,但同时,我希望带有图片的用户出现在没有图片的用户之前

I want my users to be sorted by last_activity, but at the same time, i want the users with pictures to appear before the ones without

类似这样的东西:

SELECT some_cols
FROM `prefix_users`
WHERE (some conditions)
ORDER BY last_activity, pic_set DESC;

推荐答案

SELECT some_cols
FROM prefix_users
WHERE (some conditions)
ORDER BY pic_set DESC, last_activity;

这篇关于mysql按多个项目查询顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 23:32