View Full Version : mysql OR statement output

10-30-2007, 04:25 AM
I'm trying to figure out the output statements in one using or's but I need to make sure its the best way to out put it.

$sql_test = "SELECT can_seller_custom_attribute_values.custom_attribute_value, can_seller_custom_attribute_values.custom_attribute_id FROM can_seller_custom_attribute_values WHERE can_seller_custom_attribute_values.custom_attribute_id='46' OR can_seller_custom_attribute_values.custom_attribute_id='47' OR can_seller_custom_attribute_values.custom_attribute_id='48' AND can_seller_custom_attribute_values.seller_customers_id = '1'";
$rs = mysql_query($sql_test);
$arry = mysql_fetch_array($rs);

Is that The best way to handle it?

10-30-2007, 04:36 AM
You can use the "IN" clause to make it more readable... Also you need to use parenthesis when mixing "OR"s and "AND"s.

10-30-2007, 05:03 AM
The value field changes depending on the ID so that should work still right?