架构一些particualr部分:SIDS谁提供使用嵌套查询
供应商(SID:整数,SNAME:字符串,地址:字符串)
零部件(PID:整数,PNAME:字符串,颜色:字符串)
_Catalog(SID:整数,PID:整数,成本:真正的)
,问题是:
查找供应商的红色部分供应商的位置,或者位于Packer大道221 。
我已经尝试了不同的方法,如:
方法1:
select sid
from Suppliers
where sid = (select pid
from parts
where color= 'Red')
or address='221 Packer Ave';
方法2:
select sid
from _Catalog
where (pid IN(select pid from Parts where color='Red')
OR
sid IN(select sid from Suppliers where address='221 Packer Ave'));
在第二种方法中没有显示输出,并在第一种方法中返回错误Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
我在做什么错?还有其他解决方案吗?
注:我需要一个嵌套查询来解决这个问题,因为我还没有研究过连接和推进的东西。
如果你正在使用的sqlserver ..为什么标签mysql的??????? – scaisEdge
@scaisEdge感谢您纠正我:) – Weaboo