UNION is a data manipulation language command that vertically combines the results of two or more SELECT statements but retains only unique rows. It requires that the result sets of the merged SELECT statements have the same number of columns and data types, and can only handle compatible data types (for example, you cannot combine numeric columns with string columns).
UNION in Oracle
What is UNION?
UNION is a Data Manipulation Language (DML) command that combines the results of two or more SELECT statements into a new result set.
How UNION works
The UNION operation vertically combines the result sets of two SELECT statements. However, it only retains unique rows. This means that it automatically removes duplicate rows that appear in the result set.
UNION syntax
<code>SELECT 列名1, 列名2, ... FROM 表名1 UNION SELECT 列名1, 列名2, ... FROM 表名2;</code>
UNION usage
UNION can be used in various scenarios, such as:
Example
Consider the following example:
<code>SELECT employee_id, employee_name FROM employees UNION SELECT customer_id, customer_name FROM customers;</code>
This UNION operation creates a result set containing the ID cards and names of all employees and customers.
Notes
You need to pay attention to the following when using UNION:
The above is the detailed content of What does union mean in oracle?. For more information, please follow other related articles on the PHP Chinese website!