0
0
SQLquery~10 mins

Multiple LEFT JOINs in one query in SQL - 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 all columns from table1 and left join table2 on id.

SQL
SELECT * FROM table1 LEFT JOIN table2 ON table1.id = table2.[1];
Drag options to blanks, or click blank then click option'
Aname
Bvalue
Cdate
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column that does not exist in table2.
Joining on columns with different meanings.
2fill in blank
medium

Complete the code to add a second LEFT JOIN to table3 on user_id.

SQL
SELECT * FROM table1 LEFT JOIN table2 ON table1.id = table2.id LEFT JOIN table3 ON table1.[1] = table3.user_id;
Drag options to blanks, or click blank then click option'
Aid
Bname
Cuser_id
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Joining on columns with different data types.
Using a column that does not exist in table1.
3fill in blank
hard

Fix the error in the join condition to correctly join table4 on order_id.

SQL
SELECT * FROM table1 LEFT JOIN table4 ON table1.order_id = table4.[1];
Drag options to blanks, or click blank then click option'
Aorder_id
Borderid
Cid
Duser_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using a similar but incorrect column name like 'orderid'.
Joining on unrelated columns.
4fill in blank
hard

Fill both blanks to join table2 and table3 correctly on their respective keys.

SQL
SELECT * FROM table1 LEFT JOIN table2 ON table1.[1] = table2.[2] LEFT JOIN table3 ON table1.user_id = table3.user_id;
Drag options to blanks, or click blank then click option'
Aid
Buser_id
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up user_id and id columns.
Using columns that don't exist in the tables.
5fill in blank
hard

Fill all three blanks to join table1, table2, and table3 with correct keys and aliases.

SQL
SELECT t1.*, t2.info, t3.details FROM table1 AS t1 LEFT JOIN table2 AS t2 ON t1.[1] = t2.[2] LEFT JOIN table3 AS t3 ON t1.[3] = t3.user_id;
Drag options to blanks, or click blank then click option'
Aid
Cuser_id
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' instead of 'id' or 'user_id' for joins.
Mixing up aliases and table names.