UNION - Combining Query Results1 / 10
The
Notice which rows belong to both tables, and whether they appear as duplicates in the result (hint: they don't).
UNION operator combines the results of multiple queries and removes duplicates. Try:SELECT title FROM action_movies UNION SELECT title FROM scifi_movies;
Notice which rows belong to both tables, and whether they appear as duplicates in the result (hint: they don't).
| movie_id | title | release_year | box_office_millions |
|---|---|---|---|
| 1 | The Dark Knight | 2008 | 1005 |
| 2 | Gladiator | 2000 | 460 |
| 3 | The Bourne Ultimatum | 2007 | 444 |
| 4 | Casino Royale | 2006 | 616 |
| 5 | Avatar | 2009 | 2923 |
| 6 | Iron Man | 2008 | 585 |
| movie_id | title | release_year | box_office_millions |
|---|---|---|---|
| 1 | Avatar | 2009 | 2923 |
| 2 | Inception | 2010 | 836 |
| 3 | The Matrix Reloaded | 2003 | 741 |
| 4 | War of the Worlds | 2005 | 603 |
| 5 | Minority Report | 2002 | 358 |
| 6 | Iron Man | 2008 | 585 |
Ctrl+Enter to submit
UNION - Combining Query Results - Free SQL Practice Online
Practise UNION - Combining Query Results with 10 free, interactive SQL exercises. You type real queries into your browser and get instant feedback on every answer - no database setup, no install, and no signup. It is a fast, hands-on way to learn SQL online and build query skills you can use at work.