bschultz Posted April 18, 2012 Share Posted April 18, 2012 I have a select statement in a function that I need to tweak. I needed to add a field to the database, and now the current select won't work. Here's the select: $sql = "SELECT row_number, title, $priCASE FROM new_audio WHERE (`client_id` = '$client' or `corporation` = '$corporate') AND (`start_date` <= '$now' AND `end_date` >= '$now') AND `$dow` = '1' AND `is_active` = '1' AND (`start_hour` <= '$hour' AND `end_hour` >= '$hour') AND `priority` IN ($priIN) ORDER BY priSort, last_play ASC LIMIT 1"; $client and $corporate used to be hard coded. For instance, client id 1 would be store A. Client id 2 would be store B. Client id 3 would be BOTH STORE A AND STORE B. I've now put that info into another db table, so that I can consolidate about 10 scripts into 1. As the info is now, if $client = 0, the commercial to play is a CORPORATE-WIDE ad (plays at ALL locations of a company). If this is the case, the $corporate field has that company's corporate id in it. If not, it's a STORE-SPECIFIC ad...that only plays at the on location. In this case, the $client will have a value (not 0), while the $corporate field will be 0. How should I change the select to account for NOT SELECTING a client that equals 0 or a CORPORATE that equals 0...considering that is in the current select as an OR...and it should be an OR? Quote Link to comment https://forums.phpfreaks.com/topic/261145-need-some-help-with-a-select/ Share on other sites More sharing options...
fenway Posted April 21, 2012 Share Posted April 21, 2012 "Another DB table"? Which table? How is is related? Quote Link to comment https://forums.phpfreaks.com/topic/261145-need-some-help-with-a-select/#findComment-1339310 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.