我正在使用 MySQL。这是我的架构:
供应商(sid:整数,sname:字符串,地址字符串)
部分(pid:整数,pname:字符串,颜色:字符串)
目录(sid:整数,pid:整数,成本:实数)
(主键加粗)
我正在尝试编写一个查询来选择至少由两个供应商制造的所有零件:
-- 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 - 组功能的使用无效
我究竟做错了什么?