2
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 2 tables and deletes in both at once.
Everything works well. But I need to create a parole that says:
if on the table entanglement there is no record whose field idEmail
is equal to idEmail
table Emails referenced in query, the query delete the table record Emails and disregard the table entanglement.
What would that be like query?
If on the table
emailsacompanhamento
no records, I only delete the table recordemails
or do nothing? It got a little confusing for me.– Roberto de Campos
Only delete the record in the emails table
– Carlos Rocha
And if there are records on the table
emailsacompanhamento
? Delete both?– Roberto de Campos
Already used the cascade drop?
– Tiago Ferezin
This, if there is email and there is no companion, only delete the email. And if there are both delete everything
– Carlos Rocha