Learn SQL Join,Inner Join, Outer Join

For Example:

Table A have 12( 8+4) entries, 8 entries have valid relation with B
Table B have 80(77+3) entries , 77 entries have valid relation with A.

then the return amount of join is :
cross join : 12*80
inner join : 77
full outer join : 77+4+3
left outer join: 77 + 4
right outrer join: 77 + 3


INNER Join code as the following:

Select * from A a, B b where a.categoryID = b.categoryID;
equals:
Select * from A a inner join B b on a.categoryID = b.categoryID;

OUTER Join code as the following

select * from A a full(left/right) outer  join B b  on a on a.categoryID = b.categoryID;

left/right outer join claus specific  for MSSQL:
Select * from A a, B b where a.categoryID  *=    bcategoryID;
elect * from A a, B b where a.categoryID      =*   b.categoryID;

left/right outer join claus specific for Oracle:
Select * from A a, B b where a.categoryID       =   b.categoryID(+);
Select * from A a, B b where a.categoryID (+) =  b.categoryID;


Good Resources:
http://www.w3schools.com/sql/sql_join.asp
http://www.techonthenet.com/sql/joins.htm

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值