-1
As you did not specify the database, I am responding in SQL SERVER, and tables from my database;
You can take advantage of the "deleted id" table something like:
begin transaction;
declare @deletedIds table ( id int );
delete e
output p.IdPessoa into @deletedIds
from Pessoas p
join Estados e
on e.IdPessoa = p.IdPessoa
delete P
from Pessoas P
join @deletedIds d
on d.id = P.IdPessoa;
commit transaction;
You can take the table id with the "output" note that the table that is the first to be deleted is the one that has dependency relation in this case (States).
Your error speaks of constraints breach error, you can disable them before deleting the records.
– Roknauta
-1 For the code and information that are attached in images.
– Marcelo de Andrade
What do you mean? Could you please be more explicit?
– Miguel Henriques
Miguel, welcome. The ideal is that you report the error and the code in the question itself making use of formatting. Thus avoid the use of the image. See more here: http://answall.com/help/asking
– Emerson JS
Which database? Do you want to delete all data from this table that has relation to another? or delete the data of the two tables that have the same relation?
– Marco Souza