Oracle Union | union - oracle tutorial - sql tutorial
Learn oracle - oracle tutorial - Oracle union - oracle examples - oracle programs
What is Oracle UNION ?
- The Oracle UNION operator is used to combine the result sets of 2 or more Oracle SELECT statements.
- It removes duplicate rows between the various SELECT statements.
- Note : Each SELECT statement within the UNION operator must have the same number of fields in the result sets with similar data types.
Oracle Union Query
- We have a table called wikitechy_employee with four fields (id, name, position, and city). It contains the following data:
- We have another table called orders with three fields (id, customer_name, and orderid).
oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , plsql
- There must be same number of expressions in both SELECT statements.
- Select statement is used to select city column from the wikitechy_employee table and similarly city column from orders table.
- Union Keyword is used to combines distinct values in city column from both tables.
- If several employee and customers share same city, each city will only be selected.
- Note: Use Union All keyword instead of union to select all the duplicate values.