所以我坚持尝试制作一个 SQL 来抓取对特定 COLUMN 具有相同值的每一行。
示例:
表格:买家
aID | bID aID | bID
1 | 3 1 | 3
1 | 4 1 | 2
1 | 2 2 | 2
1 | 5 1 | 4 this one also should return aID = 1
since aID =1 is present for every different bID
我想我很接近:
SELECT aID
FROM buyers
WHERE COUNT(bID) = (SELECT S1.aID
FROM buyers S1,
buyers S2
WHERE S1.aID = S2.bID
AND S2.bID <> S1.bID)
它必须在一列中的每一行中,否则不要得到它,所以如果一个aID
不同,那就不要得到它。anaID
必须与每个匹配bID