Using OR in a SELECT statement

From: Date: Tue, 28 Mar 2006 06:40:07 +0000
Subject: Using OR in a SELECT statement
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-41621@lists.php.net to get a copy of this message
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

« previous php.db (#41621) next »