34,590
社区成员
发帖
与我相关
我的任务
分享
--1)查询所有职工工资都多于1210 元的仓库的信息。
select * from 仓库表 a where not exists(select * from 职工表 where 工资<=1210 and 仓库号=a.仓库号)
and exists(select * from 职工表 where 工资>1210 and 仓库号=a.仓库号)
--2)查询向北京的供应商发出了订购单的仓库所在城市。
select [城市] from 仓库表 a
where exists(select * from 职工表 b,供应商表 c,订购单表 d
where a.仓库号=b.仓库号 and b.职工号=d.职工号 and c.供应商号=d.供应商号 and c.地址='北京')
--3)查询有职工工资大于或等于“WH1”仓库中所有职工工资的仓库号。
select distinct a.仓库号 from 仓库表 a,职工表 b
where a.仓库号=b.仓库号
and b.工资>(select max(工资) from 职工表 where 仓库号='WH1')
--4)查询仓库中还没有职工的仓库信息。
select * from 仓库表 a where not exists(select * from 职工表 where 仓库号=a.仓库号)
-- my name is sinpoal
---- 不好意思哈。职工表取别名的格式错!
----特意修改!!
--2
select c.城市 from 仓库表 c ,职工表 z,订购单表 d, 供应商表 g
where (c.仓库号=z.仓库号 and z.职工号=d.职工号
and d.供应商号=g.供应商号 and g.供应商名='北京' )
--3
select c.仓库号 from 仓库表 c , 职工表 z --here
where z.工资 >=(select max(z.工资) from 仓库表 c inner join 职工表 z
on c.仓库号=z.仓库号
where c.仓库号='WH1')
--4
select c.仓库号 from 仓库表 c, 职工表 z --here
where not exists (select z.职工号 from 仓库表 c full join 职工表 z
on c.仓库号=z.仓库号 )
-- my name is sinpoal
-- 第一题楼上的兄弟已经给你回答了哈--
--2
select c.城市 from 仓库表 c ,职工表 z,订购单表 d, 供应商表 g
where (c.仓库号=z.仓库号 and z.职工号=d.职工号
and d.供应商号=g.供应商号 and g.供应商名='北京' )
--3
select c.仓库号 from 仓库表 c , z.职工表
where z.工资 >=(select max(z.工资) from 仓库表 c inner join 职工表 z
on c.仓库号=z.仓库号
where c.仓库号='WH1')
--4
select c.仓库号 from 仓库表 c, z.职工表
where not exists (select z.职工号 from 仓库表 c full join 职工表 z
on c.仓库号=z.仓库号 )
1
SELECT * FROM TB T WHERE NOT EXISTS(SELECT 1 FROM TB WHERE SALARY<1210)