0
0
DBMS Theoryknowledge~10 mins

Union, intersection, difference in DBMS Theory - Interactive Code Practice

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

Complete the SQL query to find all unique records from two tables using union.

DBMS Theory
SELECT * FROM table1 [1] SELECT * FROM table2;
Drag options to blanks, or click blank then click option'
AJOIN
BUNION
CINTERSECT
DEXCEPT
Attempts:
3 left
💡 Hint
Common Mistakes
Using INTERSECT instead of UNION
Using JOIN which combines columns, not rows
2fill in blank
medium

Complete the SQL query to find common records between two tables.

DBMS Theory
SELECT * FROM table1 [1] SELECT * FROM table2;
Drag options to blanks, or click blank then click option'
AINTERSECT
BUNION
CEXCEPT
DJOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION which returns all unique rows
Using EXCEPT which returns differences
3fill in blank
hard

Fix the error in the SQL query to find records in table1 but not in table2.

DBMS Theory
SELECT * FROM table1 [1] SELECT * FROM table2;
Drag options to blanks, or click blank then click option'
AEXCEPT
BINTERSECT
CUNION
DJOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INTERSECT which returns common records
Using UNION which returns all unique records
4fill in blank
hard

Fill both blanks to create a query that finds records in table1 but not in table2, and removes duplicates.

DBMS Theory
SELECT [1] * FROM table1 [2] SELECT * FROM table2;
Drag options to blanks, or click blank then click option'
AEXCEPT
BUNION
CDISTINCT
DINTERSECT
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION instead of EXCEPT
Not removing duplicates with DISTINCT
5fill in blank
hard

Fill all three blanks to create a query that finds records common to both tables and orders them by id.

DBMS Theory
SELECT * FROM table1 [1] SELECT * FROM table2 ORDER BY [2] [3];
Drag options to blanks, or click blank then click option'
AINTERSECT
Bid
CASC
DDESC
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNION instead of INTERSECT
Ordering by wrong column or direction