- 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;
- Instant Testing with CasperJS
- 自己動手寫搜索引擎
- Delphi程序設(shè)計基礎(chǔ):教程、實驗、習(xí)題
- Oracle Database In-Memory(架構(gòu)與實踐)
- Mastering Ember.js
- NumPy Essentials
- 基于差分進(jìn)化的優(yōu)化方法及應(yīng)用
- Python深度學(xué)習(xí):模型、方法與實現(xiàn)
- Tableau 10 Bootcamp
- Spring+Spring MVC+MyBatis從零開始學(xué)
- 青少年學(xué)Python(第2冊)
- SAS編程演義
- 計算機(jī)常用算法與程序設(shè)計教程(第2版)
- C++從零開始學(xué)(視頻教學(xué)版)(第2版)
- 開發(fā)者測試