0
Views
3
Comments
Delete 2 tables in the same query
Question
How can i delete 2 tables in the same advanced query? Like this:

DELETE {REGISTO_UTILIZADOR},{REQUERENTE}
FROM {REGISTO_UTILIZADOR} LEFT JOIN {REQUERENTE} ON {REGISTO_UTILIZADOR}.[RegistoId]={REQUERENTE}.[RegistoId]
WHERE {REGISTO_UTILIZADOR}.[RegistoId] =@RegistoId

2011-08-23 22-04-05
Tiago Simões
Staff

Hi Filipe,

 

Have you thought about changing the delete rule in the reference attribute to delete?

In that case you would only need to delete the records in one entity and the corresponding records in the other entity would also be deleted.

 

Cheers,

Tiago Simões

2024-01-05 16-00-17
Filipe Lourenço
Yes but in some cases we cant edit the database
2011-08-23 22-04-05
Tiago Simões
Staff

Hi Filipe,

 

In that case you should do 2 advanced queries and they will run in the same transaction (all db actions in an request will run in the same transaction unless there is an explicit commit).

 

Cheers,

Tiago Simões

 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.