PostgreSQL - Joins in PostgreSQL
Consider these tables:
id | name
1 | HR
2 | IT
3 | Sales
id | dept_id | name
1 | 2 | Alice
2 | 2 | Bob
3 | 4 | Carol
What will this query return?
departmentsid | name
1 | HR
2 | IT
3 | Sales
employeesid | dept_id | name
1 | 2 | Alice
2 | 2 | Bob
3 | 4 | Carol
What will this query return?
SELECT departments.name, employees.name FROM departments RIGHT JOIN employees ON departments.id = employees.dept_id ORDER BY employees.id;