RIGHT JOIN
RIGHT JOIN is a SQL clause in the JOIN Types category. Returns ALL rows from the right table and matching rows from the left. Opposite of LEFT JOIN. The syntax is SELECT * FROM table1 RIGHT JOIN table2 ON table1.column = table2.column;. It returns all right table rows + matches. A typical example: SELECT e.name, d.dept_name FROM employees e RIGHT JOIN departments d ON e.dept_id = d.id; -- All departments, even if no employees A close relative is INNER JOIN, which returns only rows where there is a match in BOTH tables. The most common JOIN type. A close relative is LEFT JOIN, which returns ALL rows from the left table and matching rows from the right. Unmatched right rows show NULL. A close relative is FULL OUTER JOIN, which returns ALL rows from both tables. NULLs where no match exists. Not supported in MySQL. More about this category: Table join operations — INNER, LEFT, RIGHT, FULL, CROSS, SELF JOIN.