mysql error: [1064: 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 'AND f.id = g.id
and f.m_category = 4


ORDER BY f.tiff_id' at line 24] in EXECUTE("
SELECT
DISTINCT f.id, f.tiff_id, f.l_category, f.m_category, f.premiere, f.pirrow_word, f.title1, f.director,
f.copyright, f.description, f.director, f.title2, f.title3, g.*, f.promo_word,
l.name as l_name,
m.name as m_name
FROM
film f
LEFT JOIN
schedule sch on f.id = sch.id
LEFT JOIN
l_category l
ON
f.locale = l.locale AND f.l_category = l.id
LEFT JOIN
m_category m
ON
f.locale = m.locale AND f.m_category = m.id AND l.id = m.l_category
LEFT JOIN
film_genre g
ON
f.id = g.id
WHERE
f.locale =
AND f.id = g.id
and f.m_category = 4


ORDER BY f.tiff_id
;
")