如何在mysql中按特定顺序排列?

时间:2017-03-09 21:53:52

标签: mysql

我有这张桌子

name        level
Dion        Leader
Roy         Member
Gerald      Member
Boyz        Assistant
Jade        Member
Gulliver    Leader
Ananda      Assistant
Vervada     Member

我想在此表中执行ORDER BY。所以,第一个显示的是Leader,然后是助手,然后是成员,并且它们也按照他们的名字排序。

我正在寻找的输出:

name        level
Dion        Leader
Gulliver    Leader
Ananda      Assistant
Boyz        Assistant
Gerald      Member
Jade        Member
Roy         Member
Vervada     Member

我当前的查询是(虽然没有提供正确的输出):

SELECT name,level FROM t_user ORDER BY level='Leader' DESC, level='Assistant' DESC

注意:如果可能,查询必须尽可能轻/快。因为t_user有5k ++行。

0 个答案:

没有答案