Set Operators

Operators:

  • UNION: Combines results and removes duplicates.
  • UNION ALL: Combines results and retains duplicates.
  • INTERSECT: Returns common records from both SELECT statements.
  • MINUS: Returns records from the first SELECT statement that are not in the second.

Example:

SELECT first_name FROM employees
UNION
SELECT first_name FROM managers;

Explanation: This retrieves unique first names from both the employees and managers tables.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *