1

有没有一种简单的方法可以在 SQL 中执行 IN ALL 命令?

例如,如果我有:

SELECT * FROM [table] WHERE col IN (1,2) 

这实际上与以下内容相同:

SELECT * FROM [table] WHERE col = 1 OR col = 2

但我真正想要的是:

SELECT * FROM [table] WHERE col = 1 AND col = 2
4

1 回答 1

2
SELECT id
FROM [table]
WHERE col IN (1,2) 
group by id
having count(distinct col) = 2
于 2012-04-04T18:22:09.643 回答