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 'and p.ped_data_abertura LIKE "%" and DATE(res_prazo_sigilo) < DATE("2024-04-29")' at line 6
error: SELECT p.ped_codigo, r.res_dis_legal, r.res_grau_sigilo, p.ped_data_abertura, r.res_prazo_sigilo, r.res_data_resposta, r.res_assunto
FROM esic_pedidos p
LEFT JOIN esic_resposta r ON p.ped_codigo = r.ped_codigo
WHERE
r.agc =
and p.ped_data_abertura LIKE "%" and DATE(res_prazo_sigilo) < DATE("2024-04-29");