[SQL-error] SELECT a.Id_advertisement ,ag.IsPriority FROM t_advertisement as a LEFT JOIN t_advertisement_group as ag ON (a.Id_advertisement_group = ag.Id_advertisement_group) LEFT JOIN t_advertisement_display as ad ON (ad.Id_campaign = ag.Id_advertisement_group) WHERE a.StartDate <= 1481190601 AND a.EndDate >= 1481190601 AND a.IsActive = 1 AND ag.IsActive = 1 AND a.Id_advertisement_format = 8 AND ad.Id_category =  You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1