我必须找到所有供应商的名称,其中有目录中的所有汽车零部件的供应商与id = 101有,使用EXISTS或ALL或ANY。
Providers是第一个包含id和nameProvider的表。
Catalog是第二个表,其中包含id和idp (汽车零部件的id)
查询:
select nameProvider
from Providers
where id in (select id from Catalog where id = 101);我的陈述中遗漏了什么?谢谢!
发布于 2020-12-15 23:45:12
在相关子查询中使用减号运算符和with not exists可以很好地过滤掉
中不需要Provider id = 101
select nameProvider
from Providers p
where p.id != 101
and not exists (
select idp from Catalog c1 where c1.id = 101
minus
select idp from Catalog c2 where c2.id = p.id
)
;https://stackoverflow.com/questions/65308446
复制相似问题