架構一些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