QnaList > Groups > Mysql-General > Jul 2008
faq

Order Of Items In A WHERE...IN Clause

Hello,
Is it permissible to order a clause such that the search term is the
first item (in the clause)?
standard:
field1 IN (123, 654, 789)
in question:
123 IN (field1, field2, field3)
I am interested to know if the optimizer treats this any differently
if anybody can shed any light on it (except for the obvious difference
in the above queries!)
Thanks,
Andy

asked Jul 28 2008 at 09:57

Andrew Martin 's gravatar image



3 Replies for : Order Of Items In A WHERE...IN Clause
Both are valid syntax where 1 is returned if the expression is equal to 
any of the values in the list. I can't see the optimizer treating these 
any differently.
Thanks,
Gary M. Josack

answered Jul 28 2008 at 11:32

Gary Josack 's gravatar image


Andrew Martin , [email protected]
Any difference will come up in an EXPLAIN.  To run one, put the word
EXPLAIN in front of the SQL statement:
  EXPLAIN sql_statement;
Just my 0.00000002 million dollars worth,
  Shawn
"Where there's duct tape, there's hope."
"Perl is the duct tape of the Internet."
        Hassan Schroeder, Sun's first webmaster

answered Jul 28 2008 at 12:15

Mr. Shawn H. Corey 's gravatar image


Related discussions

Tagged

Group Mysql-general

asked Jul 28 2008 at 09:57

active Jul 28 2008 at 12:15

posts:4

users:4

©2013 QnaList.com