日期:2014-05-16  浏览次数:20664 次

左右连接

???? 一直以来左右连接非常糊涂,今天终于看了一遍

?

一:内连接,常用的就是这种,只显示复合条件的行

??? select * from t1 ,t2 where t1.pid=t2.pid;

?

二:外连接

??? 1: t1左连接t2

??????? select * from t1 ,t2 where t1.pid=t2.pid(+);

??????? select * from t1 left outer join t2 on t1.pid=t2.pid;

???? 这个时候会显示t1的所有值,t2没有匹配的补null

??? 2:右连接,相反,t2表全有,t1中不存在的null补齐

?

??? 3:全连接 select * from t1,t2 没有where 条件,为两表的笛卡尔积.