0
0
SQLquery~10 mins

LEFT JOIN execution behavior 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 records from the left table and matching records from the right table.

SQL
SELECT * FROM employees LEFT JOIN departments ON employees.department_id [1] departments.id;
Drag options to blanks, or click blank then click option'
A>
B!=
C=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '=' causes no matches.
Using '>' or '<' does not correctly join related rows.
2fill in blank
medium

Complete the code to count employees without a department.

SQL
SELECT COUNT(*) FROM employees LEFT JOIN departments ON employees.department_id = departments.id WHERE departments.id [1] NULL;
Drag options to blanks, or click blank then click option'
A=
BIS
CLIKE
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '= NULL' which always returns false.
Using 'LIKE NULL' which is invalid.
3fill in blank
hard

Fix the error in the LEFT JOIN query to correctly show all customers and their orders.

SQL
SELECT customers.name, orders.id FROM customers [1] JOIN orders ON customers.id = orders.customer_id;
Drag options to blanks, or click blank then click option'
ALEFT
BRIGHT
CFULL
DINNER
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes customers without orders.
RIGHT JOIN reverses the table order.
FULL JOIN includes unmatched rows from both tables.
4fill in blank
hard

Fill both blanks to create a LEFT JOIN that shows all products and their sales, including products with no sales.

SQL
SELECT products.name, sales.amount FROM products [1] JOIN sales ON products.id [2] sales.product_id;
Drag options to blanks, or click blank then click option'
ALEFT
BRIGHT
C=
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using RIGHT JOIN excludes products without sales.
Using '!=' in ON clause causes incorrect matches.
5fill in blank
hard

Fill all three blanks to write a LEFT JOIN query that lists students with grades above 80.

SQL
SELECT students.name, grades.score FROM students [1] JOIN grades ON students.id [2] grades.student_id WHERE grades.score [3] 80;
Drag options to blanks, or click blank then click option'
ALEFT
B=
C>
DINNER
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN (D) instead of the required LEFT JOIN.
Using '<' or '=' instead of '>' in the WHERE clause.
Using '!=' in ON clause causes wrong matches.