Schema:
Suppliers(sid: integer, sname: string, address: string)
Parts(pid: integer, pname: string, color: string)
_Catalog(sid: integer, pid: integer, cost: real)
And the question is:
Find the sids of suppliers who supply some red part or are at 221 Packer Ave.
I've tried different methods like:
Method 1:
select sid
from Suppliers
where sid = (select pid
from parts
where color= 'Red')
or address='221 Packer Ave';
Method 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'));
It shows no output in the 2nd method and returns an error in the 1st method Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
What am i doing wrong? and Is there any other, solution to this?
NOTE: I need a nested query to solve this problem, because I've not studied joins and advance stuff yet.