union 跟 order by同時使用 MySQL中union和order by一塊兒使用的方法

 

sql:html

select null id, '' activity_name from dual
union all
(select id,activity_name from activity where is_delete=0 order by 1 desc limit 1000)

結果就是:mysql

第一行是空行,後面開始則是根據id倒序排列的數據sql

 

mysql下 不加 limit 條件則沒法排序post

 

 

 

參考資料:url

一、 MySQL中union和order by一塊兒使用的方法spa

相關文章
相關標籤/搜索