RIGHT JOIN (also called RIGHT OUTER JOIN) is a set-operator that combines two tables based on a join condition. The operation keeps every row from the right-hand table (the second table listed in the query). If a row in the right table has no corresponding match in the left table, the query still returns the right-table row and fills the left-table columns with NULL values. Functionally, a RIGHT JOIN is equivalent to swapping table order in a LEFT JOIN, and most optimizers internally rewrite it that way. RIGHT JOIN is defined in the SQL-92 standard and is widely supported. Caveats: some databases disallow RIGHT JOIN in certain views or derived tables, and older SQLite versions (before 3.39) lack support.
left_table
(table) - First (left) input tableright_table
(table) - Second (right) input table whose rows are all preservedjoin_condition
(boolean) - Expression that links the two tablesSQL-92
They are the same. The keyword OUTER is optional and purely descriptive.
Yes. Swap table order and use LEFT JOIN. Most optimizers do this internally.
Absolutely. Combine conditions with AND or OR inside the ON clause.
If no matching row exists in the left table, every selected column from the left side is returned as NULL.