Using OR in a SELECT statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Newbie MySQL question...

I have a situation where if I don't have a custom value then I must use the
default value. There will always be a default value but there may also be a
custom value.

I could do this with:

select value where id and custom condition
if (EOF) {
  select value where id and default condition
  if (EOF) {
    // no value found for this id - error, return false
  }
}
// return value


If I change this to:

select value where id and (custom condition or default condition)

... will I always get the custom value if there is one, or do I have to have
2 selects to be sure that I always get the custom value if there is one? IE
does MySQL consistently read and process the OR statement from left to right
or does it change depending on what's most optimal?

Cheers
Arno

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux