ERROR: 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 av.ID_ANALISE = ana.ID AND av.ID_PARAMETRO = pa.ID AND ana.DATA_COLETA <= '-' at line 1 | SELECT av.ID_PARAMETRO, av.valor, DATE_FORMAT(ana.DATA_COLETA, '%b/%Y') as DATA_LAUDO_FORMATED, pa.NOME as PARAMETRO FROM la_analisevalor av, la_analise ana, cliente_laudo la, cliente_laudo_parametro pa where la.ID_LAUDO_TIPO = 2 AND ana.ATIVO = 1 AND ana.SUBTITULO = '6' AND ana.FINALIZADO = 1 AND (av.valor is not null and av.valor != '') AND la.ID = ana.ID_CLIENTE_LAUDO AND la.NOME like '%Torre de resfriamento%' AND (ana.IGNORAR_RELATORIO IS NULL OR ana.IGNORAR_RELATORIO=0) AND ana.ID_CLIENTE= AND av.ID_ANALISE = ana.ID AND av.ID_PARAMETRO = pa.ID AND ana.DATA_COLETA <= '--30' AND ana.DATA_COLETA >= ('--30' - interval 6 month) AND (pa.NOME like 'PH' OR pa.NOME like 'STD' OR pa.NOME like 'DUREZA%' OR pa.NOME like 'ALCALINIDADE%') order by DATA_COLETA DESC