使用mysql用union並子集中用order by排序順序會混亂
1. (select id from a order by start_time asc)
union all
(select id from b order by start_time desc) limit 0, 20
這樣的寫法會導致排序混亂
解決方法如下
2.
select * from
(select id from a order by start_time asc) t1
union all
select * from
(select id from b order by start_time desc) t2 limit 0, 20
這樣就解決了 union子集需要再包一層才有作用