SELECT * FROM skating WHERE year BETWEEN 2010 AND 2014 UNION SELECT * FROM cycling WHERE year BETWEEN 2010 AND 2014;
Some caveats:
By default, UNION
removes duplicate rows. UNION ALL
can remedy this.
SELECT * FROM cycling WHERE country = 'Germany' UNION ALL SELECT * FROM skating WHERE country = 'Germany'; SELECT country FROM cycling UNION ALL SELECT country FROM skating;
INTERSECT
only shows the rows which belong to BOTH tables.
SELECT year FROM cycling WHERE country = 'Germany' INTERSECT SELECT year FROM skating WHERE country = 'Germany'; SELECT person FROM cycling INTERSECT SELECT person FROM skating;
It shows all the results from the first (left) table with the exception of those that also appeared in the second (right) table.
SELECT person FROM cycling WHERE country = 'Germany' EXCEPT SELECT person FROM skating WHERE country = 'Germany'; SELECT country FROM cycling EXCEPT SELECT country FROM skating;