0
0
PostgreSQLquery~10 mins

LEFT JOIN and RIGHT JOIN in PostgreSQL - 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 customers and their orders, including customers without orders.

PostgreSQL
SELECT customers.name, orders.order_id FROM customers [1] orders ON customers.id = orders.customer_id;
Drag options to blanks, or click blank then click option'
ALEFT JOIN
BRIGHT JOIN
CINNER JOIN
DFULL JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes customers without orders.
RIGHT JOIN would keep all orders, not customers.
2fill in blank
medium

Complete the code to select all orders and their customers, including orders without customers.

PostgreSQL
SELECT orders.order_id, customers.name FROM orders [1] customers ON orders.customer_id = customers.id;
Drag options to blanks, or click blank then click option'
AFULL JOIN
BINNER JOIN
CLEFT JOIN
DRIGHT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes orders without customers.
Using LEFT JOIN would keep all orders, not customers.
3fill in blank
hard

Fix the error in the join to include all employees and their departments, even if some employees have no department.

PostgreSQL
SELECT employees.name, departments.dept_name FROM employees [1] departments ON employees.dept_id = departments.id;
Drag options to blanks, or click blank then click option'
AINNER JOIN
BLEFT JOIN
CRIGHT JOIN
DCROSS JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes employees without departments.
RIGHT JOIN keeps all departments, not employees.
4fill in blank
hard

Fill both blanks to select all products and their suppliers, including products without suppliers.

PostgreSQL
SELECT products.name, suppliers.name FROM products [1] suppliers ON products.supplier_id [2] suppliers.id;
Drag options to blanks, or click blank then click option'
ALEFT JOIN
B=
C!=
DRIGHT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using RIGHT JOIN would keep all suppliers, not products.
Using '!=' in ON condition is incorrect for matching.
5fill in blank
hard

Fill all three blanks to select all orders, their customers, and their shipping info, including orders without customers or shipping info.

PostgreSQL
SELECT orders.id, customers.name, shipping.address FROM orders [1] customers ON orders.customer_id [2] customers.id [3] JOIN shipping ON orders.shipping_id = shipping.id;
Drag options to blanks, or click blank then click option'
ALEFT JOIN
B=
CLEFT
DINNER
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN excludes orders without customers or shipping info.
Using '!=' in ON condition is incorrect.