Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果 IN 语句中的任何值匹配,SQL“in”子句将返回值。但是,如果我们想返回一个值,“IN”中的所有值都应该匹配呢?
您可以使用GROUP BY和HAVING过滤掉记录,例如。
GROUP BY
HAVING
SELECT yourColumn FROM tableName WHERE otherColumn IN ('a','b','c') GROUP BY yourColumn HAVING COUNT(*) = 3 -- <== the number of values in the WHERE clause