0
0
MySQLquery~10 mins

UNION and UNION ALL in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to combine results from two tables without duplicates.

MySQL
SELECT name FROM employees [1] SELECT name FROM managers;
Drag options to blanks, or click blank then click option'
AUNION
BINTERSECT
CUNION ALL
DJOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION ALL when duplicates should be removed.
Using JOIN which combines rows differently.
2fill in blank
medium

Complete the code to combine all rows from two tables, including duplicates.

MySQL
SELECT city FROM customers [1] SELECT city FROM suppliers;
Drag options to blanks, or click blank then click option'
AUNION
BUNION ALL
CINTERSECT
DEXCEPT
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION which removes duplicates.
Using INTERSECT which returns only common rows.
3fill in blank
hard

Fix the error in the code to correctly combine two SELECT queries.

MySQL
SELECT id, name FROM products [1] SELECT id, name FROM inventory;
Drag options to blanks, or click blank then click option'
AJOIN
BUNION
CUNION ALL
DWHERE
Attempts:
3 left
💡 Hint
Common Mistakes
Using JOIN which causes syntax error here.
Using WHERE which is invalid between SELECT statements.
4fill in blank
hard

Fill both blanks to combine two queries and order the results by name.

MySQL
SELECT name FROM staff [1] SELECT name FROM contractors [2] name;
Drag options to blanks, or click blank then click option'
AUNION
BORDER BY
CUNION ALL
DGROUP BY
Attempts:
3 left
💡 Hint
Common Mistakes
Placing ORDER BY before UNION.
Using GROUP BY instead of ORDER BY for sorting.
5fill in blank
hard

Fill all three blanks to combine two queries, keep duplicates, and sort by city.

MySQL
SELECT city FROM customers [1] SELECT city FROM vendors [2] city [3];
Drag options to blanks, or click blank then click option'
AUNION ALL
BORDER BY
CASC
DGROUP BY
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION instead of UNION ALL which removes duplicates.
Using GROUP BY which groups rows instead of sorting.