select distinct B.* from ads_banner as B ,ads_banzone WHERE B.bannerid=ads_banzone.bannerid AND ads_banzone.zoneid in ( 183,-1) AND B.farmid=18 AND weight > 0 and showcount < maximpressions AND validtodate >= now() AND validfromdate <= now() AND (( ishtml=1 ) OR ( clickcount < maxclicks ) ) ORDER BY weight * RAND() DESC limit 0,1 - Got error 28 from storage engine