0
0
PostgreSQLquery~10 mins

Why joins are essential in PostgreSQL - Test Your Understanding

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 two tables joined on a common column.

PostgreSQL
SELECT * FROM employees [1] departments ON employees.department_id = departments.id;
Drag options to blanks, or click blank then click option'
AJOIN
BSELECT
CWHERE
DGROUP BY
Attempts:
3 left
💡 Hint
Common Mistakes
Using SELECT instead of JOIN causes syntax errors.
Using WHERE without JOIN does not combine tables properly.
2fill in blank
medium

Complete the code to get employee names and their department names using a join.

PostgreSQL
SELECT employees.name, [1].name FROM employees JOIN departments ON employees.department_id = departments.id;
Drag options to blanks, or click blank then click option'
Aemployees
Bprojects
Cmanagers
Ddepartments
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting from the wrong table causes errors or wrong results.
Using a table not joined in the query causes errors.
3fill in blank
hard

Fix the error in the join clause to correctly join employees and departments.

PostgreSQL
SELECT * FROM employees JOIN departments ON employees.[1] = departments.id;
Drag options to blanks, or click blank then click option'
Aid
Bdepartment_id
Cname
Ddept_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column name causes join errors.
Mixing up primary and foreign keys leads to wrong results.
4fill in blank
hard

Fill both blanks to select employee names and their project names using a join.

PostgreSQL
SELECT employees.[1], projects.[2] FROM employees JOIN projects ON employees.project_id = projects.id;
Drag options to blanks, or click blank then click option'
Aname
Bid
Ctitle
Ddepartment_id
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting wrong columns leads to confusing results.
Using IDs instead of names or titles does not show meaningful data.
5fill in blank
hard

Fill all three blanks to select employee names, department names, and project titles using joins.

PostgreSQL
SELECT employees.[1], departments.[2], projects.[3] FROM employees JOIN departments ON employees.department_id = departments.id JOIN projects ON employees.project_id = projects.id;
Drag options to blanks, or click blank then click option'
Aname
Btitle
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up column names causes wrong output.
Using 'id' instead of descriptive columns shows numbers, not names.