order by a desc,b desc与order by a,b desc的区别

order by a desc,b desc与order by a,b desc的区别

通过下面sql看出 order by 默认是asc 。相当于select * from order_table order by id1 asc

order by a desc,b desc与order by a,b desc的区别

通过下面两个图可知,

 select * from order_table order by id1,id2 desc不等于 select * from order_table order by id1 desc,id2 desc.

select * from order_table order by id1,id2 desc等于select * from order_table order by id1 asc,id2 desc

order by a desc,b desc与order by a,b desc的区别

order by a desc,b desc与order by a,b desc的区别

通过上图和下图可知,select * from order_table order by id1 desc,id2 desc不等于 select * from order_table order by id2 desc,id1 desc.谁在前优先级高,先排序id1,id1相同的情况下再排序id2

order by a desc,b desc与order by a,b desc的区别

上一篇:枚举


下一篇:mysql sql优化 & 事务处理特征 & 约束添加、删除