外连接基础

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 [OUTER] 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. For all rows in A that have no matching rows in B, Oracle 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 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.

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 [OUTER] JOIN syntax in the FROM clause.
注意:
If A and B are joined by multiple join conditions, then you must use the (+) operator in all of these conditions. If you do not, then Oracle will return only the rows resulting from a simple join, but without a warning or error to advise you that you do not have the results of an outer join.

如果有多张表进行连接,例abc连接,a和c用了外联,则以后a和c的每个字段的连接条件都要加上外联,否则,a和c等同于内联;而a和b,b和c的连接不受影响。

为什么会这样的个人解释:a和c外联了,假设a左联c,有一个条件加上了(+)a.name = c.name(+)也就是说这时的结果集里面的数据包括a.name为空的数据;此时,还有一个条件是这样的a.id = c.id,这个时候,取出的数据,里面的name是为空呢还是不为空?我想oracle也很为难,所以,就选择了一个办法,让这个(+)相当于没有生效。

而a和b的结果集,b和c的结果集,没有影响,该怎么出就怎么出。

欢迎拍砖。

你可能感兴趣的:(oracle,C++,c,C#)