2つのクエリがあります。どちらも1つの結合条件でのみ異なります。 1つのクエリにする方法はありますか。同じ種類の結合を持つ2つのクエリを結合する
最初のクエリ:
delete from Employee where Employee_ID in
(
select PK from Dept
inner join Tran on Tran.PK = Dept.TX_ID
inner join TASK on TASK.TRANSINFO = TRAN.PK_ID
inner join TASK1 on TASK.PT_ID = TASK1.PK_ID
inner join TASKSUB on TASKSUB.PK_ID = TASK1.SUBJECT
where TASKSUB. PK1 in (select id from tmp) and TASKSUB.REF= ‘Shopping’
);
2のクエリ:
delete from Employee where Employee_ID in
(
select PK from Dept
inner join Tran on Tran.PK = Dept.TX_ID
inner join TASK on TASK.TRANSINFO = TRAN.PK_ID
inner join TASK1 on TASK.PT_ID = TASK1.PK_ID
inner join TASKSUB on TASKSUB.PK_ID = TASK1.SUBJECT
where TASKSUB. PK1 in (select id1 from tmp) and TASKSUB.REF= ‘Shopping’
);
唯一の違いは、TMPテーブルにIDとID1です。