To understand the correct answer, let's break down the options:
- UNION ALL – Retrieves all rows, including duplicates, from both queries.
- UNION – Retrieves distinct records from both queries, removing duplicates.
- MINUS or EXCEPT – Retrieves rows from the first
SELECT statement not found in the second SELECT statement.
- INTERSECT – Retrieves only the rows common to both
SELECT statements.
- COPY INTO – Offers an idempotent method for incrementally ingesting data from external systems, with expectations like consistent data schema and handling of duplicate records downstream.
The correct command to find common records is INTERSECT.