SELECT p.*, pl.alt AS lang_alt, pl.view_label AS lang_view_label, pbg.alt AS bg_alt, pbg.view_label AS bg_view_label FROM pr_products_pic AS p LEFT JOIN AS pl ON pl.pic_id=p.id AND pl.language='bg' LEFT JOIN AS pbg ON pbg.pic_id=p.id AND pbg.language='bg' WHERE p.item_id='68' ORDER BY p.sort_order You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS pl ON pl.pic_id=p.id AND pl.language='bg' ' at line 4