其實這麼寫理論上是對的,不少博客教程都是這樣子寫的。。優化
select * from (SELECT * FROM article WHERE is_top=0 ORDER BY id DESC) as t1排序
union教程
select * from (SELECT * FROM article WHERE is_top=1 ORDER BY start_time desc) as t2博客
而後仍是發現子查詢的排序無效,尷尬,後來才發現若是order by 不帶limit,會被優化器幹掉,致使語句就是:it
select * from (SELECT * FROM article WHERE is_top=0 ) as t1io
unionselect
select * from (SELECT * FROM article WHERE is_top=1) as t2nio
解決方案:im
select * from (SELECT * FROM article WHERE is_top=0 ORDER BY id DESC limit 999999) as t1查詢
union
select * from (SELECT * FROM article WHERE is_top=1 ORDER BY start_time desc limit 999999) as t2