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 posted the answer a query like this
SELECT * FROM table_name where val1 IN (column_name)
As you can see here the position of the column_name and values are interchanged.
From Mysql Docs
expr IN (value,...)
Returns 1 if expr is equal to any of the values in the IN list, else returns 0. If all values are constants, they are evaluated according to the type of expr and sorted. The search for the item then is done using a binary search. This means IN is very quick if the IN value list consists entirely of constants.
mysql> SELECT 2 IN (0,3,5,7);
-> 0
mysql> SELECT 'wefwf' IN ('wee','wefwf','weg');
-> 1
As it clearly says that the above one(my query) is correct. but both the above queries produce the same output.
Also why not the other approach in listed in Mysql Documentation?
This question serves as a canonical information source regarding the use of IN. Its purpose is to have detailed, high quality answers detailing the proper use on IN in queries.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…