【SQL】UNION ALL 與UNION 的區別
SQL> select product_id,product_type_id ,name
2 from products
3 union all
4 select prd_id,prd_type_id ,name
5 from more_products order by 1;
PRODUCT_ID PRODUCT_TYPE_ID NAME
---------- --------------- ------------------------------
1 1 Modern Science
1 1 Modern Science
2 1 Chemistry
2 1 Chemistry
3 2 Supernova
3 Supernova
4 2 Tank War
4 2 Lunar Landing
5 2 Submarine
5 2 Z Files
6 2 2412: The Return
7 3 Space Force 9
8 3 From Another Planet
9 4 Classical Music
10 4 Pop 3
11 4 Creative Yell
12 My Front Line
已選擇17行。
union all 返回查詢資料集的所有行,
SQL> select product_id,product_type_id ,name
2 from products
3 union
4 select prd_id,prd_type_id ,name
5 from more_products;
PRODUCT_ID PRODUCT_TYPE_ID NAME
---------- --------------- ------------------------------
1 1 Modern Science
2 1 Chemistry
3 2 Supernova
3 Supernova
4 2 Lunar Landing
4 2 Tank War
5 2 Submarine
5 2 Z Files
6 2 2412: The Return
7 3 Space Force 9
8 3 From Another Planet
9 4 Classical Music
10 4 Pop 3
11 4 Creative Yell
12 My Front Line
已選擇15行。
UNION 返回資料集中所有非重複的行。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-673251/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Union與Union All的區別
- sql中UNION和UNION ALL的區別SQL
- union all和union的區別
- union和union all的區別
- sql中union和union allSQL
- SQL Union和SQL Union All用法(轉)SQL
- sql中union和union all的用法SQL
- Union和Union All到底有什麼區別
- SQL UNION 和 UNION ALL 操作符SQL
- MySQL學習(五) UNION與UNION ALLMySql
- 查詢集合操作union與union all
- sql_union all_列別名SQL
- SQL UNION 操作符 和 UNION ALL 操作符SQL
- Oracle中的Union、Union All、Intersect、MinusOracle
- 理解full outer jion,union,union all
- sql_intersect交集_minus差集_並集union_union allSQL
- ORACLE中union/union all/Intersect/Minus用法Oracle
- oracle知識整理(1) union和union all的區別,left join和right join的區別(各種join的區別)Oracle
- Oracle 中Union、Union All、Intersect、Minus(並,交,差)Oracle
- Oracle的集合操作(union、union all、intersect、minus集合函式)Oracle函式
- UNION效率比UNION ALL效率高——SQL優化之Everything is possibleSQL優化
- msyql jion 和 union 的區別
- union, struct, enum 的 大小區別Struct
- union all 最佳化案例
- 【轉】UNION效率比UNION ALL效率高——SQL優化之Everything is possibleSQL優化
- Struct 和 Union有下列區別Struct
- Oracle union all 不走索引的優化Oracle索引優化
- 透過union all把sql查詢的結果拼接起來SQL
- MYSQL學習筆記24: 多表查詢(聯合查詢,Union, Union All)MySql筆記
- sql注入之union注入SQL
- 表連線 join和(+)、union和uion allUI
- 【SQL 學習】UNION 的排序方式!SQL排序
- MySQL中使用or、in與union all在查詢命令下的效率對比MySql
- 銀彈谷V平臺VSQL使用distinct與union all使用SQL
- 簡單測試在儲存過程中臨時表與union all的效能差別儲存過程
- SQL優化案例-union代替or(九)SQL優化
- union用法
- C++ 結構體struct和共同體union的區別C++結構體Struct