JOIN statistics as s
ON c.id=s.campaign_id
LEFT JOIN adv_campaigns_platforms as cp
ON s.platform_id = cp.platform_id
AND s.type_id=#{STATS_TYPE_APPROVAL}
AND s.uid=?
AND s.platform_id=?
WHERE s.id IS NULL
AND c.status=3
AND cp.adv_campaign_id IS NULL
Этот вариант уже устарел)
and adv_campaign_id != s.campaign_id же?
SELECT c.* FROM adv_campaigns as c LEFT JOIN statistics as s ON c.id=s.campaign_id AND s.type_id=? AND s.uid=? LEFT JOIN adv_campaigns_platforms as cp ON s.platform_id = cp.platform_id WHERE s.id IS NULL AND c.status=3 — это я не понял зачем AND cp.adv_campaign_id IS NULL and ( s.platform_id != ? —???? s.platform_id is null or cp.adv_campaign_id !=s.platform_id ) укоротил
Обсуждают сегодня