Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2007
    Location
    maine,usa
    Posts
    151
    Thanks
    2
    Thanked 1 Time in 1 Post

    mysql OR statement output

    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.
    PHP Code:
        $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?
    Just a simple Developer and IT student
    My Blog
    My Portfolio
    My Playground of Technology

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You can use the "IN" clause to make it more readable... Also you need to use parenthesis when mixing "OR"s and "AND"s.

  • #3
    Regular Coder
    Join Date
    Aug 2007
    Location
    maine,usa
    Posts
    151
    Thanks
    2
    Thanked 1 Time in 1 Post
    The value field changes depending on the ID so that should work still right?
    Just a simple Developer and IT student
    My Blog
    My Portfolio
    My Playground of Technology


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •