- MySQL 8 for Big Data
- Shabbir Challawala Jaydip Lakhatariya Chintan Mehta Kandarp Patel
- 179字
- 2021-08-20 10:06:14
UNION
The UNION keyword is used to combine the results from multiple select queries into a single table. Each SELECT statement used in a UNION query must have the same number of columns and each column must require a similar data type. The column names from the first SELECT statement are used as the columns for the results returned.
For example, the Employee table:

For example, Contractor table:

The column names from the first SELECT statement are used as the columns for the results returned as shown in following example.
SELECT 'Employee' As Type, name, city, country FROM Employee
UNION
SELECT 'Contractor', name, city, country FROM Contractor;
The following example of UNION removes duplicate rows from the result; if we don't want to remove duplicate rows, the ALL keyword can be used:
SELECT country FROM Employee UNION SELECT country FROM Contractor;
This query returns two rows from the preceding table--Germany and Mexico. To fetch all rows from both these tables, we can use the ALL keyword as follows:
SELECT country FROM Employee UNION ALL SELECT country FROM Contractor;
- Qt 5 and OpenCV 4 Computer Vision Projects
- 零基礎(chǔ)學(xué)C++程序設(shè)計
- Vue.js 3.0源碼解析(微課視頻版)
- aelf區(qū)塊鏈應(yīng)用架構(gòu)指南
- Java Web開發(fā)技術(shù)教程
- Big Data Analytics
- Python機器學(xué)習(xí)經(jīng)典實例
- NoSQL數(shù)據(jù)庫原理
- Java 從入門到項目實踐(超值版)
- Django Design Patterns and Best Practices
- OpenCV Android Programming By Example
- 零基礎(chǔ)學(xué)C語言(第4版)
- Anaconda數(shù)據(jù)科學(xué)實戰(zhàn)
- 邊玩邊學(xué)Scratch3.0少兒趣味編程
- Oracle Database XE 11gR2 Jump Start Guide