List:General Discussion« Previous MessageNext Message »
From:Mr. Shawn H. Corey Date:July 28 2008 12:15pm
Subject:Re: order of items in a WHERE...IN clause
View as plain text  
On Mon, 2008-07-28 at 07:32 -0400, Gary Josack wrote:
> Andrew Martin wrote:
> > 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
> >
> >   
> 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
> 
> 
> 

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

Thread
order of items in a WHERE...IN clauseAndrew Martin28 Jul
  • Re: order of items in a WHERE...IN clauseGary Josack28 Jul
    • Re: order of items in a WHERE...IN clauseMr. Shawn H. Corey28 Jul
      • Re: order of items in a WHERE...IN clauseMoon's Father25 Oct