I have the following query :
DELETE FROM emails,emailsacompanhamento
USING emails,emailsacompanhamento
WHERE emails.idEmail = emailsacompanhamento.idEmail AND
emails.idEmail = ".$idEmail
That makes a kind of JOIN
in tables and delete in both in one go.
Everything works fine. But I need to create a conditional that says:
If there is no record whose idEmail
field is equal to idEmail
of the Emails table referenced in emails table > query , the query deletes the record of the Emails table and disregards the emails table.
How would this query be?