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 excluido IN ('0','2') ORDER BY ordem' at line 1 - SELECT `filial_topico`.*, DATE_FORMAT(data_alteracao, '%d/%m/%Y %H:%i:%s') as data_alteracao2,DATE_FORMAT(data_cadastro, '%d/%m/%Y %H:%i:%s') as data_cadastro2 FROM `filial_topico` WHERE filial_fk = AND excluido IN ('0','2') ORDER BY ordem