SELECT roomno,type,price from room where price<='100'order by roomno desc,price desc 關鍵是最后一局,倒出來的結果只顯示 roomno desc,不顯示price desc 我知道m(xù)ysql不支持循環(huán),但這個問題怎么解決呢?
2 回答

小怪獸愛吃肉
TA貢獻1852條經(jīng)驗 獲得超1個贊
出現(xiàn)這種情況那說明roomno的一列數(shù)據(jù)都不相同,如果price的一列有相同的數(shù)據(jù),那應改為:
SELECT roomno,type,price
from room
where price<='100'
order by price,roomno DESC;
如下例:
SELECT name, species, birth FROM pet
ORDER BY species, birth DESC;
結果為:
name | species | birth |
+----------+---------+------------+
| Chirpy | bird | 1998-09-11 |
| Whistler | bird | 1997-12-09 |
| Claws | cat | 1994-03-17 |
| Fluffy | cat | 1993-02-04 |
| Fang | dog | 1990-08-27 |
| Bowser | dog | 1989-08-31 |
| Buffy | dog | 1989-05-13 |
添加回答
舉報
0/150
提交
取消