left ,right ,cross ,full/left outer join/区别 详解
2015-10-30 00:01
567 查看
--创建测试表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.序号
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.序号
相关文章推荐
- 项目冲刺,第二天
- 在eclipse中运行上面程序总是提示Multiple markers at this line
- 做技术和做业务的区别
- 数据结构队列
- nutch2 crawl 命令分解,抓取网页的详细过程
- 关于Hibernate执行查询后会引发update操作的解决方法
- 天嵌科技参加TI10月解决方案研讨会(杭州站)
- 计算机的硬件基础
- 某检察院创新机制促涉案财物管理规范化
- vs 中程序被锁定的问题
- php链接SQL_Server数据库
- iOS反向传值demo--代理方法
- iOS反向传值-----系统单例方法
- iOS反向传值--Block方法
- MySQL 64位安装程序下载地址与安装教程
- Xcode6/Xcode7中如何去掉默认的Main.storyboard for swift语言
- Xcode7.1下用CocoaPods安装Alamofire--swift下的第三方网络库
- windows下Android利用ant自动编译、修改配置文件、批量多渠道,打包生成apk文件
- linux(以ubuntu为例)下Android利用ant自动编译、修改配置文件、批量多渠道,打包生
- Unknown URL content://downloads/my_downloads