p.s., if you reply, kindly CC me as well. 

hi, i have the following SQL query 

  select col1 from table1 
  where 
  col2 = 'xxx' or col3 = 'xxx'

how can i get rid of this OR? due to my table design and the logic
involved, i have to check both these 2 columns (in a search function). i
cannot concaneate them to make a third column because i need to check for
exact match but for both the columns. 

the EXPLAIN gives me the "ALL" type, which of course is not optimal. if i
remove the OR in the above SQL, and make only one condition, then this
EXPLAIN comes back as "const". this is ideal! and what i want. 

so what can i do to replace the OR? in a curious fit, i tried :

  select col1 from table1 
  where 
  'xxx' in (col2, col3)

and to my surprise this works!!! but the EXPLAIN returns "ALL" again. so
it is useless..

thanks in advance for any insight/ideas! 

.ep

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to