Invalid query: 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 'ORDER BY uk.datum_start ASC' at line 1 SELECT u.*, uk.universalis_korisnik_ID, uk.datum_start, uk.datum_end FROM universalis_korisnik uk LEFT JOIN universalis u ON uk.ID = u.ID WHERE uk.status_ID = 1 AND ORDER BY uk.datum_start ASC