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 5 (1064). Query: select c.id, l.langUKR as deflang, coalesce(l.langEN, l.langUKR) as sname, c.pid, c.nlevel, c.nstate, c.stype, c.nname, c.nhaschildren /*, cc.pid as nhaschildren2*/ from r_catalog as c /*left join r_catalog as cc on cc.pid=c.id */ left join r_lang as l on c.nname = l.id where c.pid =