UNION 聯合查詢時 子查詢中包含order by的處理
阿新 • • 發佈:2019-02-14
select * from ( SELECT top 10 * FROM [article_info] where typeid=1 order by addDate desc ) as t1 UNION select * from ( SELECT top 10 * FROM [article_info] where typeid=2 order by addDate desc ) as t2 UNION select * from ( SELECT top 10 * FROM [article_info] where typeid=3 order by addDate desc ) as t3 UNION select * from ( SELECT top 10 * FROM [article_info] where typeid=4 order by addDate desc ) as t4 UNION select * from ( SELECT top 10 * FROM [article_info] where typeid=5 order by addDate desc ) as t5 UNION select * from ( SELECT top 10 * FROM [article_info] where typeid=6 order by addDate desc ) as t6
採用 select * from (臨時表) as xx 的方式可以實現