按照自己的理解做个笔记,以下在Sql Server2005和Oracle92中都运行通过:
create table a(
aid varchar(2),
aname varchar(10),
bid varchar(2) );
create table b(
bid varchar(2),
bname varchar(10));
insert into a values(‘s1′,’sname1′,’c1’);
insert into a values(‘s2′,’sname2′,’c2’);
insert into a values(‘s3′,’sname3′,’c3’);
insert into a values(‘s4′,’sname4′,’c4’);
insert into a values(‘s5′,’sname5′,’c5’);
insert into b values(‘c1′,’cname1’);
insert into b values(‘c2′,’cname2’);
insert into b values(‘c3′,’cname3’);
insert into b values(‘c6′,’cname6’);
insert into b values(‘c7′,’cname7’);
–Iner Join和Join和, (如select * from a,b where a.id=b.id),这三个效果一样.
select * from a , b where a.bid = b.bid;
select * from a join b on a.bid = b.bid;
select * from a inner join b on a.bid = b.bid;
–Left Join和Left Outer Join 左连接、左外连接,效果一样。
select * from a left join b on a.bid = b.bid;
select * from a left outer join b on a.bid = b.bid;
–Right Join和Right Outer Join 右连接、右外连接,效果一样。
select * from a right join b on a.bid = b.bid;
select * from a right outer join b on a.bid = b.bid;
–Full Join和Full Outer Join 全连接、全外连接,效果一样。
select * from a full join b on a.bid = b.bid;
select * from a full outer join b on a.bid = b.bid;
–Cross Join,不带where,即笛卡尔积。
select * from a Cross join b;
总结:只有以上的的连接词,像什么Left Inner Join、Right Full Join之类的组合都没有,想都别想!!
转载于:https://www.cnblogs.com/ouc3www/archive/2009/02/20/1394627.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/110941.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...