PDA

View Full Version : selecting from mysql with 2 conditions


corey84
04-19-2006, 11:27 PM
Hi I was wondering how you would select results from a table with multiple conditions

i thought maybe something like this

$sql = "SELECT * from table WHERE con1 = '$con1', con2 = '$con2'";



but not working :( any help appreciated

BTW if this belongs in the database forum sorry :)

corey84
04-20-2006, 03:24 AM
okay i figured it out


$sql = "SELECT * FROM table WHERE con1 =$con1 AND con2 = $con2";

scoutt
04-20-2006, 12:55 PM
or if they both don't have to be true then this will work

$sql = "SELECT * FROM table WHERE con1 ='$con1' OR con2 = '$con2'";