I have these 3 tables, and i want to delete from all records except some already used request
- Registry
- Record
- Request
and i use this query which brings me all the rows i want to delete.
select * from Record where RegistryId = 'aa6598' except select * from Record where Id in ( select RecordId from Request where RegistryId = 'aa6598')
How to use delete in this case?
Advertisement
Answer
delete Record where RegistryId = 'aa6598' and Id not in ( select RecordId from Request where RegistryId = 'aa6598')