RE: PHP/MySQL question

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

 



[snip]
I need to do an OR search on three columns, and AND the rest, anyone
have a good way to do this?  So far my searching on the MySQL lists have
been fruitless more then anything, and I figured we've probably come
across this ourselves at some point.
[/snip]

More of a MySQL question, but easily enough answered;

Always group the OR with parenthese and the AND individually. Write the
query and test with MySQL before placing into PHP code;

SELECT * FROM `table`
WHERE (`foo` = 'bar' 
   OR `foo` = 'glorp'
   OR `sqirk` = 'glorp')
AND `today` = CURDATE()
AND `userID` = 'Marvin'

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux