There are 2 tables: report (which has a primary key of reportId and a bit field called migrated) and report_detail (which has a foreign key of reportId). I want to delete all the rows from report_detail that have a reportId which, in the report table, has migrated = 1. This is the select query that selects all the rows I want:
select *
from report r inner join report_detail d
on r.reportId = d.reportId
where migrated = 1
Will this delete query do what I want or am I doing something wrong?
delete from report_detail
where exists(
select *
from report r inner join report_detail d
on r.reportId = d.reportId
where migrated = 1
)