0
0
MySQLquery~10 mins

INTERSECT equivalent 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 select common names from two tables using INNER JOIN.

MySQL
SELECT a.name FROM table1 a INNER JOIN table2 b ON a.[1] = b.name;
Drag options to blanks, or click blank then click option'
Aid
Bvalue
Cname
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using different column names in the ON clause.
Using a column that does not exist in one of the tables.
2fill in blank
medium

Complete the code to find common ids using EXISTS to simulate INTERSECT.

MySQL
SELECT id FROM table1 t1 WHERE EXISTS (SELECT 1 FROM table2 t2 WHERE t2.[1] = t1.id);
Drag options to blanks, or click blank then click option'
Aid
Bvalue
Cname
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong column in the subquery.
Forgetting to correlate the subquery with the outer query.
3fill in blank
hard

Fix the error in the query to simulate INTERSECT using IN clause.

MySQL
SELECT name FROM table1 WHERE name [1] (SELECT name FROM table2);
Drag options to blanks, or click blank then click option'
AIN
BNOT IN
C=
DLIKE
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which compares only one value, not a list.
Using NOT IN which returns non-matching rows.
4fill in blank
hard

Fill both blanks to simulate INTERSECT using INNER JOIN with aliasing.

MySQL
SELECT [1].id FROM [2] a INNER JOIN table2 b ON a.id = b.id;
Drag options to blanks, or click blank then click option'
Aa
Btable1
Ctable_one
DtableA
Attempts:
3 left
💡 Hint
Common Mistakes
Using different aliases in SELECT and FROM.
Using a wrong table name.
5fill in blank
hard

Fill all three blanks to simulate INTERSECT using EXISTS with correct table aliases and column.

MySQL
SELECT [1].name FROM [2] [1] WHERE EXISTS (SELECT 1 FROM [3] WHERE [3].name = [1].name);
Drag options to blanks, or click blank then click option'
At1
Btable1
Ctable2
Dt2
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent aliases.
Mixing up table names in the subquery.