

For all rows in B that have no matching rows in A, Oracle returns null for any select list expressions containing columns of A. To write a query that performs an outer join of tables A and B and returns all rows from B (a right outer join), use the RIGHT JOIN syntax in the FROM clause, or apply the outer join operator (+) to all columns of A in the join condition in the WHERE clause. For all rows in A that have no matching rows in B, Oracle Database returns null for any select list expressions containing columns of B. To write a query that performs an outer join of tables A and B and returns all rows from A (a left outer join), use the LEFT JOIN syntax in the FROM clause, or apply the outer join operator (+) to all columns of B in the join condition in the WHERE clause. An outer join returns all rows that satisfy the join condition and also returns some or all of those rows from one table for which no rows from the other satisfy the join condition. These conditions can further restrict the rows returned by the join query.Īn outer join extends the result of a simple join. The optimizer determines the order in which Oracle joins tables based on the join conditions, indexes on the tables, and, any available statistics for the tables.Ī WHERE clause that contains a join condition can also contain other conditions that refer to columns of only one table. Oracle continues this process until all tables are joined into the result. To execute a join of three or more tables, Oracle first joins two of the tables based on the join conditions comparing their columns and then joins the result to another table based on join conditions containing columns of the joined tables and the new table.

The columns in the join conditions need not also appear in the select list. To execute a join, Oracle Database combines pairs of rows, each containing one row from each table, for which the join condition evaluates to TRUE. The join condition compares two columns, each from a different table. Most join queries contain at least one join condition, either in the FROM clause or in the WHERE clause.
