关于MYSQL中order排序的问题

SELECT roomno,type,price 
from room 
where price<='100'
order by roomno desc,price desc 
关键是最后一局,倒出来的结果只显示 roomno desc,不显示price desc 
我知道mysql不支持循环,但这个问题怎么解决呢?

慕尼黑8549860
浏览 396回答 2
2回答

慕桂英4014372

出现这种情况那说明roomno的一列数据都不相同,如果price的一列有相同的数据,那应改为:SELECT&nbsp;roomno,type,pricefrom roomwhere price<='100'order by price,roomno DESC;如下例:SELECT&nbsp;name, species, birth FROM petORDER 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 ||&nbsp;Fang&nbsp;| dog | 1990-08-27 || Bowser | dog | 1989-08-31 || Buffy | dog | 1989-05-13 |&nbsp;

斯蒂芬大帝

SELECT&nbsp;roomno,type,pricefrom roomwhere price<='100'order by roomno,price desc
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

MySQL