RIGHT JOIN (also called RIGHT OUTER JOIN) is one of the ANSI-standard outer join operators. It combines each row of the right-hand table with matching rows from the left-hand table based on a join condition supplied in an ON clause or USING clause. If no match exists in the left table, the query still returns a row, filling the selected columns from the left table with NULLs. Conceptually, it is the mirror image of LEFT JOIN: swapping the table order in a LEFT JOIN produces the same result as a RIGHT JOIN.Key points:- Only rows from the right table are guaranteed to appear.- The keyword OUTER is optional and purely syntactic.- RIGHT JOINs can be chained with other joins and filtered with WHERE, HAVING, and window functions.- Performance depends on indexes on the join columns; OUTER joins are usually executed with hash or merge join strategies.- Some engines (notably SQLite) do not support RIGHT JOIN at all; use LEFT JOIN with table order reversed instead.
left_table
(table or subquery) - produces the columns that may be NULL if no match is foundright_table
(table or subquery) - every row from this table appears at least once in the resultON clause
(boolean expression) - defines how rows from both tables are matchedUSING clause
(alternative) - column list - shorthand when the join keys share the same nameLEFT JOIN, FULL OUTER JOIN, INNER JOIN, CROSS JOIN, ON clause, USING clause, NULL handling
SQL-92 Standard
RIGHT JOIN preserves all rows from the right table, filling NULLs for non-matching rows on the left. LEFT JOIN does the opposite.
No. SQLite lacks RIGHT JOIN. Use LEFT JOIN with the tables swapped.
Use it when the natural reading of the query lists the retained table on the right or when refactoring legacy SQL that already relies on that order.
Generally no. Performance relies on indexes and the query planner, not the direction of the outer join.