The keyword representing union in SQL is UNION. It combines the results of two or more SELECT statements into a single result set that contains all unique rows, which means it combines all the rows from the two input result sets without duplicates contained in both Rows in the result set.
Keyword representing union in SQL: UNION
Union operation
The UNION keyword is used to combine the results of two or more SELECT statements into a single result set. It returns all unique rows from the two input result sets, which means it combines all the rows from the two result sets but does not duplicate the rows contained in both result sets.
Syntax
<code class="sql">SELECT_statement UNION [ALL] SELECT_statement</code>
Where:
SELECT_statement
is the SQL query to be merged. ALL
is an optional keyword that returns all rows, including duplicate rows. Usage
The UNION keyword can be used in the following scenarios:
Example
The following example merges the names from the employees
table and the customers
table into a single result set :
<code class="sql">SELECT name FROM employees UNION SELECT name FROM customers;</code>
The result set will contain all unique names from the employees
table and the customers
table.
Note:
The above is the detailed content of Keyword representing union in sql. For more information, please follow other related articles on the PHP Chinese website!