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 mb.blockLanguageGroupID =1 GROUP BY m.menuID ORDER BY m.sortIndex ASC' at line 9 SQL:"SELECT m.menuID, m.parentMenuID, m.niveau, m.title, m.header, m.state, b.blockID, b.isHomepage, b.url, b.content FROM `menu` m INNER JOIN ( SELECT * FROM `menuBlockMap` WHERE menuTypeID = 1 ORDER BY CASE WHEN blockID > 0 THEN 1 ELSE 2 END ) mb ON mb.menuID = m.menuID LEFT JOIN `block` b ON mb.blockID = b.blockID WHERE m.parentMenuID = AND mb.blockLanguageGroupID =1 GROUP BY m.menuID ORDER BY m.sortIndex ASC;"