SELECT s.*, m.*, k.name as category from products_pl as m left join products as s on s.id=m.id left join sklep_kategorie as k on s.cat=k.id where order by s.rorder asc 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 'order by s.rorder asc' at line 4