oracle 外鏈接(+)

Outer Joinsexpress

An outer join extends the result of a simple join. 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.app

  • 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 [OUTERJOINsyntax in the FROM clause, or apply the outer join operator (+) to all columns of B 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.less

  • 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 [OUTER]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 B that have no matching rows in A, Oracle returns null for any select list expressions containing columns of A.spa

  • To write a query that performs an outer join and returns all rows from A and B, extended with nulls if they do not satisfy the join condition (a full outer join), use the FULL [OUTERJOIN syntax in the FROM clause.code

You cannot compare a column with a subquery in the WHERE clause of any outer join, regardless which form you specify.orm

You can use outer joins to fill gaps in sparse data. Such a join is called a partitioned outer join and is formed using thequery_partition_clause of the join_clause syntax. Sparse data is data that does not have rows for all possible values of a dimension such as time or department. For example, tables of sales data typically do not have rows for products that had no sales on a given date. Filling data gaps is useful in situations where data sparsity complicates analytic computation or where some data might be missed if the sparse data is queried directly.ci

總結:外鏈接的話,兩表不論是否匹配成功了,都會有一表徹底返回,另一表返回null.

select ...
from a,b
where a.id=b.id(+)

等於it

SELECT ...
     FROM a
LEFT JOIN b ON b.id = a.id
相關文章
相關標籤/搜索