left ,right ,cross ,full/left outer join/区别 详解

--创建测试表ww
if OBJECT_ID('qq') is not null drop table qq
create table qq([序号] varchar(5),[内容1] varchar(10),[内容2] varchar(15))
insert into qq([序号],[内容1],[内容2])
select 'dd','zoumin','yuzulin'
union all
select 'cc','zm','yz'
union all
select 'AA','z1','yz1'
union all
select 'BB','zm2','yz2'
select * from qq
drop table qq

--创建测试表 ww

if OBJECT_ID('ww') is not null drop table ww
create table ww([序号] varchar(5),[内容1] varchar(10),[内容2] varchar(15))
insert into ww([序号],[内容1],[内容2])
select 'ee','ee','rr'
union all
select 'ff','tt','yy'
union all
select 'AA','tt1','yy1'
union all
select 'BB','tt1','yy1'
select * from ww
drop table ww

--内连接(inner可省)
select * from qq inner join ww on qq.序号=ww.序号
--On 条件可变得内连接
select * from qq inner join ww on qq.序号!=ww.序号
--交叉连接(加where 条件后=inner join)
select * from qq cross join ww where qq.序号=ww.序号

--交叉连接(逗号形式的)
select * from qq , ww where qq.序号=ww.序号
--左连接
select * from qq left join ww on qq.序号=ww.序号
--做外连接=左连接
select * from qq left outer join ww on qq.序号=ww.序号
--右连接
select * from qq right join ww on qq.序号=ww.序号
--全连接=left+right
select * from qq full join ww on qq.序号=ww.序号

上一篇:超简单的NDK单步调试方法


下一篇:PHP替换HTML文件中所有a标签的HREF属性,其他不变