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
)
укоротил
возможно тебе надо and ( s.platform_id is null or cp.adv_campaign_id !=s.platform_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.campaign_id )
Обсуждают сегодня