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 m.id_teasera=t.id order by m.kolejnosc' at line 1select t.* from cms_teaser t,cms_teas_menu m where m.id_menu= and m.id_teasera=t.id order by m.kolejnosc;