Returns all rows from the right table and matching rows from the left; NULLs fill unmatched left-side columns.
Returns all rows from the right table and matched rows from the left; non-matching left rows produce NULLs. Less commonly used than LEFT JOIN since you can usually reverse the table order. Best reserved for queries where the right table defines the canonical set.
Compatibility
| Database System | Support Status | Since Version | Notes |
|---|---|---|---|
| MySQL | Native | all | OUTER keyword is optional. |
| PostgreSQL | Native | all | OUTER keyword is optional. |
| SQL Server | Native | all | OUTER keyword is optional. |
| Oracle | Native | all | OUTER keyword is optional. Legacy syntax: WHERE a.id(+) = b.a_id |
| SQLite | Native | 3.39.0 | RIGHT JOIN added in SQLite 3.39.0 (July 2022). Rewrite as LEFT JOIN with tables swapped for older versions. |
Details
RIGHT JOIN is the mirror of LEFT JOIN. Since it can always be rewritten as a LEFT JOIN with tables swapped, it is less commonly used.
Standard Syntax
Version Support
Per-Database Syntax & Notes
MySQL Native syntax
OUTER keyword is optional.
PostgreSQL Native syntax
OUTER keyword is optional.
SQL Server Native syntax
OUTER keyword is optional.
Oracle Native syntax
OUTER keyword is optional. Legacy syntax: WHERE a.id(+) = b.a_id
SQLite Native syntax
RIGHT JOIN added in SQLite 3.39.0 (July 2022). Rewrite as LEFT JOIN with tables swapped for older versions.