Sobes.tech
Junior — Middle

Do you have experience using the UNION operator in SQL queries?

sobes.tech AI

Answer from AI

The UNION operator in SQL is used to combine the results of two or more SELECT queries into a single dataset. It returns unique rows from all queries, excluding duplicates.

Example of usage:

SELECT name FROM employees WHERE department = 'Sales'
UNION
SELECT name FROM contractors WHERE department = 'Sales';

This query will return a list of unique names from both tables.

If you want to keep duplicates, use UNION ALL.

The operator is useful for combining data from different tables or queries with the same structure.

Do you have experience using the UNION operator in… - sobes.tech