What is recommended on this site is you always show what you tried to do and if any error occurred or the obtained result was not as expected.
This is not a site to just ask them to do something for you. Usually such a question is simply rejected.
Since you’re new, I’ll show you but make a tour on how to use this site.
Try:
SELECT Clientes.* FROM Clientes INNER JOIN Ligações ON (Cliente.CNPJ = Ligações.CNPJ)
WHERE (Cliente.Data_ultima_compra < DATE_SUB(CURRENT_DATE, 60 DAY))
OR (Ligações.CNPJ IS NULL)
OR (Ligações.Data_ligação IS NOT NULL AND Ligações.Data_ligação < DATE_SUB(CURRENT_DATE, 20 DAY));
I only made the changes from Inner Join to Left Join, as the values shown will all be from the customer table. Thank you!
– Marcos ACR
Correct, typing failure. No sense testing (CNPJ links IS NULL) on an INNER JOIN.
– anonimo