SELECT a.Banner_ID, a.Campaign_ID, d.Type, h.BannerSize_Name, d.File, d.Alt, d.Text, g.Field_ID, d.NewWindow FROM (Banner_CampaignBanner AS a, Banner_CampaignZone AS b, Message282 AS c, Message280 as d, Message290 AS e, Message284 AS f, Field AS g) LEFT JOIN Classificator_BannerSize AS h ON h.BannerSize_ID=d.Size WHERE ((c.Start <= IF((c.Start IS NOT NULL OR c.Start != 0), NOW(), 0) AND c.Stop > IF((c.Stop IS NOT NULL OR c.Stop != 0), NOW(), 0)) AND IF ((c.Shows IS NOT NULL OR c.Shows != 0), (c.Showed+1), 0) <= IF ((c.Shows IS NOT NULL OR c.Shows != 0), c.Shows, 0)) AND a.Campaign_ID=b.Campaign_ID AND c.Checked=1 AND a.Campaign_ID=c.Message_ID AND b.Zone_ID='1' AND b.Zone_ID=e.Message_ID AND ((e.Site='1' AND (e.Section IS NULL OR e.Section = 0)) OR (e.Site='1' AND (e.Section='524' OR e.Section = '521')) OR ((e.Section='524' OR e.Section = '521') AND (e.Site IS NULL OR e.Site = 0)) OR (e.Class='491' AND e.Object='0') OR (e.Class='491' AND (e.Object IS NULL OR e.Object = 0))) AND f.Message_ID = d.Script AND d.Status=1 AND d.Checked=1 AND c.Size=d.Size AND d.Size=e.Size AND a.Banner_ID=d.Message_ID AND f.Message_ID=d.Script AND f.TimeZone16=1 AND f.Day2=1 AND g.Class_ID=280 AND g.TypeOfData_ID=6 AND g.Field_Name='File' ORDER BY d.`Created` DESC LIMIT 1
Рассылка

Подпишитесь на рассылку, и вы всегда будете в курсе последних событий

События
К Списку всех праздников
SELECT a.Banner_ID, a.Campaign_ID, d.Type, h.BannerSize_Name, d.File, d.Alt, d.Text, g.Field_ID, d.NewWindow FROM (Banner_CampaignBanner AS a, Banner_CampaignZone AS b, Message282 AS c, Message280 as d, Message290 AS e, Message284 AS f, Field AS g) LEFT JOIN Classificator_BannerSize AS h ON h.BannerSize_ID=d.Size WHERE ((c.Start <= IF((c.Start IS NOT NULL OR c.Start != 0), NOW(), 0) AND c.Stop > IF((c.Stop IS NOT NULL OR c.Stop != 0), NOW(), 0)) AND IF ((c.Shows IS NOT NULL OR c.Shows != 0), (c.Showed+1), 0) <= IF ((c.Shows IS NOT NULL OR c.Shows != 0), c.Shows, 0)) AND a.Campaign_ID=b.Campaign_ID AND c.Checked=1 AND a.Campaign_ID=c.Message_ID AND b.Zone_ID='10' AND b.Zone_ID=e.Message_ID AND ((e.Site='1' AND (e.Section IS NULL OR e.Section = 0)) OR (e.Site='1' AND (e.Section='524' OR e.Section = '521')) OR ((e.Section='524' OR e.Section = '521') AND (e.Site IS NULL OR e.Site = 0)) OR (e.Class='491' AND e.Object='0') OR (e.Class='491' AND (e.Object IS NULL OR e.Object = 0))) AND f.Message_ID = d.Script AND d.Status=1 AND d.Checked=1 AND c.Size=d.Size AND d.Size=e.Size AND a.Banner_ID=d.Message_ID AND f.Message_ID=d.Script AND f.TimeZone16=1 AND f.Day2=1 AND g.Class_ID=280 AND g.TypeOfData_ID=6 AND g.Field_Name='File' ORDER BY d.`Created` DESC LIMIT 1