我是SQL新手。这些SQL语句的输出是否相等?
Suppliers
(sid:integer,sname:string,address:string)Parts
(pid:integer,pname:string,color:string)Catalog
(sid:integer,pid:integer,cost:real)SQL查询#1
SELECT S.sid
FROM Suppliers S
WHERE S.address = '221 Packer street'
OR S.sid IN (SELECT C.sid
FROM Parts P, Catalog C
WHERE P.color = 'red' AND P.pid = C.pid)
SQL查询#2
SELECT S.sid
FROM Suppliers S, Parts P, Catalog C
WHERE (P.pid = C.Pid AND P.color = 'red')
OR (S.address = '221 Packer street')
答案 0 :(得分:2)
他们并不相同。如果Parts有多个行,只有一个PID,它将返回重复的供应商记录。