【发布时间】:2017-03-16 16:42:18
【问题描述】:
架构:
供应商(sid:整数,sname:字符串,地址:字符串)
零件(pid:整数,pname:字符串,颜色:字符串)
_Catalog(sid: integer, pid: integer, cost: real)
问题是:
查找供应红色零件或位于 221 的供应商的 sid 帕克大道。
我尝试了不同的方法,例如:
方法一:
select sid
from Suppliers
where sid = (select pid
from parts
where color= 'Red')
or address='221 Packer Ave';
方法二:
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 感谢您纠正我 :)
标签: sql