SQLServer多表连接查询

双表内部连接查询

select wName,dName from  DepartMent,Worker where DepartMent.dID=Worker.did
select wName,dName from DepartMent inner join Worker on DepartMent.dID=Worker.did

多表内部连接查询

select wName,dName,GName from  DepartMent,Worker,Gender
where DepartMent.dID=Worker.did and Worker.Gid = Gender.Gid
select wName,dName,GName from DepartMent
inner join Worker on DepartMent.dID=Worker.did
inner join Gender on Worker.Gid=Gender.Gid

外部连接查询

--1.左外连接查询
select wName,dName from DepartMent
left outer join Worker on DepartMent.dID=Worker.did
--2.右外连接查询
select wName,dName from DepartMent
right outer join Worker on DepartMent.dID=Worker.did
--3.完全外部连接查询
select wName,dName from DepartMent
full outer join Worker on DepartMent.dID=Worker.did
--4.交叉连接
select wName,dName from DepartMent
Cross join Worker
select wName,dName from DepartMent, Worker
上一篇:Android学习笔记(五)


下一篇:python 字符串查找