Page 1 of 1

Return two results from same column

Posted: Thu Oct 17, 2002 8:30 pm
by phpScott
Im trying to write a mysql query where I want to return a result of two possible out comes as in

select propType from sites where propType='$propType' or propType='*'

where propType=BB

I would want returned all results that would have BB in the propType column as well as * in the propType column.

Any ideas without having to make two queries to the db

phpScott

Posted: Thu Oct 17, 2002 8:50 pm
by volka
take a look at 6.3.2.1 String Comparison Functions (mysql-manual)
you can use logical operands in WHERE clauses similar to PHP
SELECT .... WHERE cond1 OR cond2 is valid

Posted: Fri Oct 18, 2002 5:33 am
by twigletmac
You can also use the IN keyword (equivalent to lots of OR statements):

Code: Select all

SELECT propType FROM sites WHERE propType IN('$propType','*')
http://www.mysql.com/doc/en/Comparison_Operators.html

Mac

thanks

Posted: Fri Oct 18, 2002 6:23 pm
by phpScott
thanks alot twigletmac :D :D that did the trick just nicely.
Much graditude.

phpScott