...

View Full Version : mysql OR statement output



moos3
10-30-2007, 03: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);
var_dump($arry);

Is that The best way to handle it?

Fumigator
10-30-2007, 03: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.

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum