Oracle Union | union - oracle tutorial - sql tutorial



Oracle union

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.

Syntax:

SELECT expression1, expression2, ... expression_n
FROM tables
[WHERE conditions]
UNION
SELECT expression1, expression2, ... expression_n
FROM tables
[WHERE conditions];
click below button to copy the code. By - oracle tutorial - team
  • 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

Oracle Union Query

Sample Database:

  • We have a table called wikitechy_employee with four fields (id, name, position, and city). It contains the following data:
 oracle union table
  • We have another table called orders with three fields (id, customer_name, and orderid).
 oracle union table
oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , plsql

Example:

SELECT City FROM wikitechy_employee
UNION
SELECT City FROM orders
ORDER BY City;
click below button to copy the code. By - oracle tutorial - team

Note:

  • There must be same number of expressions in both SELECT statements.

Union:

 union output
  1. Select statement is used to select city column from the wikitechy_employee table and similarly city column from orders table.
  2. Union Keyword is used to combines distinct values in city column from both tables.
  3. 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.

Union UnionAll Except Intersect

Union UnionAll Except Intersect

This tutorial provides an indepth knowledge on the following items such as oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , mysql tutorial , sql tutorial for beginners , learn sql , oracle database tutorial , sql query tutorial , oracle dba tutorial , plsql tutorial , oracle tutorial pdf , oracle pl sql tutorial , oracle sql tutorial , sql tutorial point , oracle tutorial for beginners , learn oracle online free , learn oracle online , learning pl sql programming , learn sql online for free , sql learning online , dba oracle tutorial , oracle sql tutorial advanced , oracle 11g dba tutorial with examples , oracle online learning , oracle learning online , how to learn pl sql , sql coding tutorial , sql learning websites , sql basic learning

Related Searches to Oracle Union | UNION