我有以下关系
Supplies
sid 1 2 3 4
sname Jason David John Peter
address 1a 2b 3c 4d
Parts
pid 10 20 30 40
pname Head Body Hand Leg
color red blue green white
Catalog
sid 1 1 2 2 3 4 1
pid 10 20 20 30 30 40 30
cost100 200 150 150 130 125 50
我想找到供应一些红色和一些绿色零件的供应商ID。
我使用查询但返回 null 我不知道为什么?(它应该返回 sid 为 1)
SELECT S.sid FROM Suppliers AS S, Parts AS P, Catalog AS C WHERE S.sid = C.sid AND C.pid = P.pid AND ( P.color = 'red' AND P.color = 'green' )
我想问一下,上面的查询和下面的查询有什么区别?(它也返回 null 但我认为它应该返回 sid 为 1)
SELECT S.sid FROM Suppliers AS S, Parts AS P1, Catalog AS C1, Parts AS P2 , Catalog AS C2 WHERE S.sid = C1.sid AND C1.pid = P1.pid AND S.sid = C2.pid AND C2.pid = P2.pid AND ( P1.color = 'red' AND P2.color = 'green' )