Today I have posted an answer with a query like this
SELECT * FROM table_name where column_name IN (val1,val2,...)
Some another user has po
you raised a question that is connected with my answer here.
In a simple explanation using this statements below,
SELECT * FROM TableName WHERE column1 IN (1, 2, 3, 4)
-- versus
SELECT * FROM TableName WHERE 1 IN (column1, column2, column3, column4)
The first statement involves only ONE COLUMN that is being compared to multiple values.
SELECT *
FROM TableName
WHERE column1 = 1 OR
column1 = 2 OR
column1 = 3 OR
column1 = 4
while the second statement is A VALUE that is compared to multiple columns.
SELECT *
FROM TableName
WHERE column1 = 1 OR
column2 = 1 OR
column3 = 1 OR
column4 = 1
which is a bit different from one another.
UPDATE 1
Here's the third form of IN clause: