【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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- sql中UNION和UNION ALL的區別SQL
- union all和union的區別
- union 和union all 使用區別
- sql中union和union all的用法SQL
- MySQL學習(五) UNION與UNION ALLMySql
- union和union all 關鍵字
- oracle知識整理(1) union和union all的區別,left join和right join的區別(各種join的區別)Oracle
- Oracle的集合操作(union、union all、intersect、minus集合函式)Oracle函式
- `FULL JOIN` 和 `UNION ALL`
- msyql jion 和 union 的區別
- union all 最佳化案例
- Struct 和 Union有下列區別Struct
- sql注入之union注入SQL
- MYSQL學習筆記24: 多表查詢(聯合查詢,Union, Union All)MySql筆記
- 銀彈谷V平臺VSQL使用distinct與union all使用SQL
- MySQL中使用or、in與union all在查詢命令下的效率對比MySql
- SQL優化案例-union代替or(九)SQL優化
- SQL最佳化案例-union代替or(九)SQL
- union用法
- union注入
- OceanBase 金融專案最佳化案例(union all 改寫)
- SQL Server中的集合運算: UNION, EXCEPT和INTERSECTSQLServer
- union存取低高位
- union和enum使用
- union 聯合體
- MySQL, Incorrect usage of UNION and ORDER BYMySql
- 組合查詢(UNION)
- [CF1517F] Union
- 並查集(Union Find)並查集
- Union Find程式碼塊
- kingbase SQL最佳化案例 ( union遞迴 改 cte遞迴 )SQL遞迴
- Analysis of Set Union Algorithms 題解Go
- Oracle優化案例-union代替or(九)Oracle優化
- SQLite語句(三):JOIN和UNIONSQLite
- WPF Path GeometryCombineMode Union, Exclude,Intersect,Xor
- 備忘:union()後paginate分頁
- 4. union-find演算法演算法
- union的兩個子查詢是否並行並行
- mysql求交集:UNION ALL合併查詢,inner join內連線查詢,IN/EXISTS子查詢MySql