赞
踩
- select 供应商.供应商号,供应商名,地址
- from 供应商 full join 订购单
- on 供应商.供应商号=订购单.供应商号
- where 职工号='E1' and 地址='北京' and 供应商.供应商号
- in
- (select 供应商号 from 订购单 where 职工号='E3')
- SELECT * FROM 供应商 WHERE 地址='北京' AND 供应商号 IN
- (SELECT 供应商号 FROM 订购单 WHERE 职工号='E1') AND 供应商号 IN
- (SELECT 供应商号 FROM 订购单 WHERE 职工号 ='E3')
- select * from 供应商 where 地址='北京' and exists (
- select * from 订购单 where 订购单.供应商号=供应商.供应商号 and 职工号='E1') and exists (
- select * from 订购单 where 订购单.供应商号=供应商.供应商号 and 职工号='E3')
- select 供应商.供应商号,供应商名,地址
- from 供应商,订购单 where 供应商.供应商号=订购单.供应商号 and 职工号='E1'
- and 地址='北京'
- intersect
- select 供应商.供应商号,供应商名,地址
- from 供应商,订购单 where 供应商.供应商号=订购单.供应商号 and 职工号='E3'
- and 地址='北京'
- --in连接
- select COUNT(*) as 供应商个数 from 供应商
- where 供应商号 in(select 供应商号 from 订购单
- where 职工号 in(select 职工号 from 职工
- where 仓库号 in(select 仓库号 from 仓库
- where 面积 in(select min(面积) from 仓库))))
- --exists连接
- select COUNT(*) as 供应商个数 from 供应商
- where exists(select * from 订购单
- where 订购单.供应商号=供应商.供应商号 and exists
- (select * from 职工 where 订购单.职工号=职工.职工号 and exists
- (select * from 仓库 where 仓库.仓库号=职工.职工号 and exists
- (select MIN(面积) from 仓库))))
- --自然连接
- select COUNT(*) as 供应商个数 from 供应商, 订购单,职工,仓库,(select MIN(面积) A from 仓库) as x
- where 订购单.供应商号=供应商.供应商号 and 订购单.职工号=职工.职工号 and 仓库.仓库号=职工.职工号 and x.A=仓库.面积
- --join连接
- select count(*) as 供应商个数
- from 供应商 join 订购单 on 订购单.供应商号=供应商.供应商号
- join 职工 on 订购单.职工号=职工.职工号 join 仓库 on 仓库.仓库号=职工.职工号
- where 面积=(select MIN(面积) from 仓库)
- --in连接
- select AVG(面积) as 平均面积 from 仓库
- where 仓库号 in(
- select 仓库号 from 职工
- where 职工号 in(
- select 职工号 from 订购单
- where 供应商号='S4') )
- --exists连接
- select AVG(面积) as 平均面积 from 仓库
- where exists(
- select * from 职工 where 职工.仓库号=仓库.仓库号
- and exists(
- select * from 订购单 where 订购单.职工号=职工.职工号 and 供应商号='S4'))
- --自然连接
- select AVG(distinct(面积)) as 平均面积 from 仓库,职工,订购单
- where 仓库.仓库号=职工.仓库号 and 职工.职工号=订购单.职工号
- and 供应商号='S4'
- --join on 连接
- select AVG(distinct(面积)) as 平均面积 from 仓库 join 职工
- on 仓库.仓库号=职工.仓库号 join 订购单 on 订购单.职工号=职工.职工号
- and 订购单.供应商号='S4'
- select 职工.职工号 from 职工,仓库,订购单
- where
- 职工.仓库号=仓库.仓库号
- and 职工.职工号=订购单.职工号
- and 城市='上海'
- and 供应商号='S6'
- group by 职工.职工号
- having COUNT(供应商号) =1
-
- select 职工.职工号 from 职工
- join 仓库 on 职工.仓库号=仓库.仓库号 and 城市='上海'
- join 订购单 on 订购单.职工号=职工.职工号
- and 供应商号='S6'
- group by 职工.职工号
- having COUNT(供应商号) =1
-
- select 职工.职工号 from 职工
- where 仓库号 in(
- select 仓库号 from 仓库 where 职工号 in(
- select 职工号 from 订购单 where 供应商号='S6' and 城市='上海'))
-
-
- select 职工.职工号 from 职工
- where exists(
- select * from 仓库 where 仓库.仓库号=职工.仓库号 and exists(
- select * from 订购单 where 订购单.职工号=职工.职工号 and 供应商号='S6' and 城市='上海'))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。