Описание тега where-in
An SQL-standard condition of the form WHERE SOME_COLUMN IN (1,2,3) or using a subquery to create the list, eg WHERE SOME_COLUMN IN (SELECT X FROM MYTABLE WHERE Y)
For example:
SELECT *
FROM MY_TABLE
WHERE MY_COLUMN IN (1,2,3,5,8,13)
or commonly using a subquery to generate the list:
SELECT *
FROM MY_TABLE
WHERE MY_COLUMN IN (
SELECT SOME_COLUMN FROM SOME_TABLE WHERE <some condition>
)
The subquery version is a source on many performance problems, because most optimizers do not optimize this properly.
Most IN (subquery)
queries can be rewritten to use a join that does perform well.