Complete the code to select all records from the right table and matching records from the left table using RIGHT JOIN.
SELECT employees.name, departments.department_name FROM employees [1] departments ON employees.department_id = departments.id;The RIGHT JOIN returns all records from the right table (departments) and the matched records from the left table (employees). If there is no match, the result is NULL on the left side.
Complete the code to get all departments and their employees, including departments with no employees.
SELECT departments.department_name, employees.name FROM departments [1] employees ON departments.id = employees.department_id;To get all departments and their employees, including departments without employees, use LEFT JOIN because departments is the left table.
Fix the error in the query to correctly use RIGHT JOIN to get all departments and their employees.
SELECT employees.name, departments.department_name FROM employees [1] departments ON employees.department_id = departments.id;The query must use RIGHT JOIN to include all departments and matching employees. Using LEFT JOIN or INNER JOIN will not include all right table rows.
Fill both blanks to select all employees and their departments, including employees without departments.
SELECT employees.name, departments.department_name FROM employees [1] departments ON employees.department_id [2] departments.id;
Use LEFT JOIN to include all employees (left table) and '=' for the join condition.
Fill all three blanks to select all departments and their employees, including departments with no employees, and order by department name.
SELECT departments.department_name, employees.name FROM departments [1] employees ON departments.id [2] employees.department_id ORDER BY departments.department_name [3];
Use LEFT JOIN to include all departments, '=' for the join condition, and ASC to order alphabetically ascending.