Conditional MySQL Query
Posted: Thu Jun 15, 2006 1:50 am
I'm trying to write a conditional query for a banner manager, I think what I have just needs to be tweaked but I can't find anything in the manual.
In English:
if Impressions + TargetedImpressions is less than DisplayLimit or if DisplayLimit is equal to 0 pull the row.
In English:
if Impressions + TargetedImpressions is less than DisplayLimit or if DisplayLimit is equal to 0 pull the row.
Code: Select all
$Query = "select `AdID` ";
$Query .= "from `" . TABLE_BANNER_MANAGER . "` ";
$Query .= "where `Status`='0' and IF(DisplayLimit != '0',(Impressions+TargetedImpressions) < DisplayLimit,1) ";
$Query .= " and `ExpireDate` <= '" . date("Y-m-d") . "'";