これが私のスキーマです:
サプライヤー(sid:整数、sname:文字列、アドレス文字列)
Parts(pid:整数、 pname:文字列、色:文字列)
カタログ(sid:整数、pid:整数、コスト:実数)
太字は主キーを示します。
すべての部品を供給しているすべてのサプライヤーを見つけるためのクエリを作成したいと思います。これが私がすでに持っている2つのクエリです:
-- get all parts for a given supplier
SELECT Parts.pid
FROM Suppliers
JOIN Catalog ON Catalog.sid = Suppliers.sid
JOIN Parts ON Parts.pid = Catalog.pid
WHERE Suppliers.sid = 4;
-- gets all parts that exist
SELECT Parts.pid
FROM Parts
私がやりたいことは、命令型で、次のようなものです。
Define result set
Foreach Supplier:
If the list of parts produced by a supplier
is equal to the total list of parts, add this supplier to the result set
Return result set
これをMySQLに変換するにはどうすればよいですか?