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 N.criado_por!='-1' AND C.autorizado='1' ORDER BY C.data DESC, C.hora DESC ' at line 1