0
我有一個產品表,我想按名稱列出產品,但如果庫存級別爲0,按名稱也是。mysql按列1排序,但是如果列2 = 0,則添加到結束,但仍按列1排序
id name quantity
1 aa 0
2 ba 12
3 ac 66
4 ab 0
這樣的結果我想是
id name quantity
3 ac 66
2 ba 12
1 aa 0
4 ab 0
千恩萬謝
我有一個產品表,我想按名稱列出產品,但如果庫存級別爲0,按名稱也是。mysql按列1排序,但是如果列2 = 0,則添加到結束,但仍按列1排序
id name quantity
1 aa 0
2 ba 12
3 ac 66
4 ab 0
這樣的結果我想是
id name quantity
3 ac 66
2 ba 12
1 aa 0
4 ab 0
千恩萬謝
select * from table order by quantity = 0, name
應該做你
ORDER BY量= 0,名稱 – Strawberry 2014-09-10 11:54:06