Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SELECT instead of JOIN causes syntax errors.
Using WHERE without JOIN does not combine tables properly.
✗ Incorrect
The JOIN keyword combines rows from two tables based on a related column.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
We select the department name from the departments table.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column name causes join errors.
Mixing up primary and foreign keys leads to wrong results.
✗ Incorrect
The department_id in employees matches the id in departments.
4fill in blank
hardFill 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'
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.
✗ Incorrect
We select name from employees and title from projects.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up column names causes wrong output.
Using 'id' instead of descriptive columns shows numbers, not names.
✗ Incorrect
Select employee name, department name, and project title.