# 聯合查詢關鍵字 union all 和 union
select * from student where Gid = (select max(Gid) from student)
union all select * from student where Gid = (select min(Gid) from student)
聯合查詢的作用:把多個 select 語句的結果進行合併。
union all 和 union的區別:union all 只是把結果進行合併,union 把合併後的結果去重
注意:哪個select語句返回的字段數量最少,那麼最終返回最大的字段數量和它相等。字段數量多的select語句,要寫字段名(個數和最終返回的字段數量相等),字段數量最少的select語句可以用 * 。