Is There Any Better Way To Write This Query
I designed below query for my delete operation. I am new to SQL and just wanted to check with experienced people here if it is fine or any better way to do this. I am using DB2 dat
Solution 1:
You can use merge like this too :
merge into TableD
using TableB tB
on B.B_id = TableD.B_id
and tB.A_id in (select A_id from TableA tA where A_id = 123)
and C_id in (1,2,3)
when matched then delete;
Solution 2:
DELETE FROM TableD tD WHERE EXISTS ( SELECT tB.B_id FROM TableB tB WHERE A_id = 123 AND tB.B_id = tD.B_id ) AND C_id IN (1, 2, 3)
Post a Comment for "Is There Any Better Way To Write This Query"