SELECT s.*, m.*, as category from products_pl as m left join products as s on left join sklep_kategorie as k on 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