如何以ASC顺序获取MySql的不同(不同)值

时间:2015-06-16 09:55:23

标签: mysql

我有桌子

像这样

--------------------------------------------
id    size    title              priority
---------------------------------------------
1       4      sample title1        2
2       2      sample title2        2
3       3      sample title3        1
4       1      sample title4        2
5       2      sample title5        1
6       3      sample title6        2
7       1      sample title7        1
8       4      sample title8        1
-------------------------------------------

我想要一个查询来获得如下输出:

--------------------------------------------
id    size    title              priority
---------------------------------------------
7       1      sample title7        1
5       2      sample title5        1
3       3      sample title3        1
8       4      sample title8        1
4       1      sample title4        2
2       2      sample title2        2
6       3      sample title6        2
1       4      sample title1        2


-------------------------------------------

所以,我想要按升序排列不同的大小值,也按升序检查优先级。

1 个答案:

答案 0 :(得分:1)

Giorgos Betsos 提到:

SELECT * FROM table_ ORDER BY priority, size  ASC;

DEMO