Chinaunix首页 | 论坛 | 博客
  • 博客访问: 125145
  • 博文数量: 31
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 355
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-16 17:21
文章分类

全部博文(31)

文章存档

2014年(1)

2012年(2)

2011年(15)

2010年(1)

2009年(8)

2008年(4)

分类:

2011-08-11 10:47:43

假设你加入列上没有重复,这是迄今为止最常见的情况:
  • An inner join of A and B gives the result of A intersect B, ie the inner part of a venn diagram intersection.的一个内部联接和B给出了一个相交乙的结果,即一个维恩图交叉口内的一部分。

  • An outer join of A and B gives the results of A union B, ie the outer parts of a venn diagram union.的一个外部联接和B赋予工会B的结果,即维恩图联盟的外部零件。

Examples 例子

Suppose you have two Tables, with a single column each, and data as follows:假设你有两个表,用一个单一的列中的每个,数据如下:

AB - - 1 3 2 4 3 5 4 6

Note that (1,2) are unique to A, (3,4) are common, and (5,6) are unique to B.注意:(1,2)是一个独特的,(3,4)是常见的,和(5,6)到B是唯一的

inner join 内部联接

An inner join using either of the equivalent queries gives the intersection of the two tables, ie the two rows they have in common.内部联接使用等效的查询给出两个表的交集,即两行,它们的共同点。

select * from a INNER JOIN b on aa = bb; select a.*,b.* from a,b where aa = bb; a | b --+-- 3 | 3 4 | 4

left outer join 左外连接

A left outer join will give all rows in A, plus any common rows in B.左外连接会给中的所有行,加上B中的任何共同行

select * from a LEFT OUTER JOIN b on aa = bb; select a.*,b.* from a,b where aa = bb(+); a | b --+----- 1 | null 2 | null 3 | 3 4 | 4 ; select * from a LEFT OUTER JOIN b on aa = bb; select a.*,b.* from a,b where aa = bb(+); a | b --+----- 1 | null 2 | null 3 | 3 4 | 4

full outer join 完整外部联接

A full outer join will give you the union of A and B, ie All the rows in A and all the rows in B. If something in A doesn't have a corresponding datum in B, then the B portion is null, and vice versa.完全外部联接会给你联盟A和B,即所有排在A和B中的所有行,如果事情在一个不具备相应的基准在B,那么B部分是空的,而副反之亦然。

select * from a FULL OUTER JOIN b on aa = bb; a | b -----+----- 1 | null 2 | null 3 |
阅读(584) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~