私はMySQLを使用しています。ここに私のスキーマがあります:
サプライヤー ( sid: 整数、sname: 文字列、アドレス文字列)
パーツ ( pid: 整数、pname: 文字列、色: 文字列)
Catalog( sid: 整数、pid: 整数、コスト: 実数)
(主キーは太字で示されています)
少なくとも 2 つのサプライヤーによって製造されたすべての部品を選択するクエリを作成しようとしています。
-- Find the pids of parts supplied by at least two different suppliers.
SELECT c1.pid -- select the pid
FROM Catalog AS c1 -- from the Catalog table
WHERE c1.pid IN ( -- where that pid is in the set:
SELECT c2.pid -- of pids
FROM Catalog AS c2 -- from catalog
WHERE c2.pid = c1.pid AND COUNT(c2.sid) >= 2 -- where there are at least two corresponding sids
);
まず、私はこれを正しい方法で行っていますか?
次に、次のエラーが表示されます。
1111 - グループ機能の無効な使用
私は何を間違っていますか?