标签:
后期会补充建表语句。
现有两张表,westemp员工表,有(wtdempid,wtdempname,wtddeptid)列,westdept部门表,有(wtddeptid,wtddeptname,wtddeptaddress)列.其中westemp.wtddeptid可以等于westdept.wtddeptid.
1.交叉连接:(用于产生笛卡尔积)(两种写法)
1.1 select * from westemp a cross join westdept b--交叉连接,用于生成笛卡尔积
1.2 .select * from westemp a,westdept b
2.自然连接(自动找寻消除笛卡尔积的条件)
select * from westemp a natural join westdept b--自然连接
3.内连接(自己指定条件消除笛卡尔积)
3.1 select * from westemp a inner join westdept b on a.wtddeptid=b.wtddeptid--内连接,
3.2 select * from westemp a join westdept b on a.wtddeptid=b.wtddeptid--内连接,
3.3 select * from westemp a,westdept b where a.wtddeptid=b.wtddeptid--内连接,
4.全外连接
select * from westemp a full outer join westdept b on a.wtddeptid=b.wtddeptid--全外连接
5.右外连接
5.1 select * from westemp a right outer join westdept b on a.wtddeptid=b.wtddeptid--右外连接
5.2 select * from westemp a,westdept b where a.wtddeptid=b.wtddeptid(+)--右外连接
6.左外连接
6.1select * from westemp a left outer join westdept b on a.wtddeptid=b.wtddeptid--左外连接
6.2select * from westemp a,westdept b where a.wtddeptid(+)=b.wtddeptid--左外连接
多表连接定义
http://www.cnblogs.com/westward/p/5148028.html
标签:
原文地址:http://www.cnblogs.com/westward/p/5177634.html