供應商誰賣只有紅色部分:「誰找只提供紅零部件供應商的小島嶼發展中國家」
Select distinct c.Sid
From Catalog c join Parts p
on p.pid = c.pid
Where p.Color = 'RED'
and Not exists
(Select * from Catalog
Where sid = c.Sid
and pid in (Select Pid from Parts
Where Color != 'RED'))
在英語中,它幾乎正是你的問題
聲明
其中,字only
轉化爲它的兩個部分....相當於
「查找誰供應紅色部分和不提供不屬於任何紅色的零部件供應商的小島嶼發展中國家。」
左右....
Select distinct c.Sid -- "Find the sids of suppliers ..."
From Catalog c join Parts p
on p.pid = c.pid
Where p.Color = 'RED' -- "who supply red parts ... "
and Not exists -- " and do not supply ..."
(Select * from Catalog -- " Parts ... "
Where sid = c.Sid
and pid in (Select Pid from Parts -- " ... That are ..."
Where Color != 'RED')) -- " ... Not Red"
你願意提供查詢的正常英文描述?我是SQL新手,它真的有幫助。 – user3577756
當然,我會將其添加到上面的答案 –