How to use JOIN in UPDATE query
I am very weak at join and i need to know that how can i convert following query using joins. This Query is working fine with sub queries but i need to convert it and use it making joins.
update dbo.TFIN_Stmt_Line_Item_Dtl set Stmt_Line_Item_Dtl_Desc='Changes from Baseline' where Stmt_Line_Item_Dtl_Desc='Increased Hours' and Stmt_Line_Item_Id in (select tmt_Line_Item_Ref_Id from dbo.TFIN_Stmt_Line_Item where Stmt_Line_Item_Type_Id = (select Stmt_Line_Item_Type_Id from dbo.TFIN_Stmt_Line_Item_Type where Stmt_Line_Item_Desc like 'ABOX/RBOX Amendment 18 and 20'))
Please if any body can help me.
Following query uses joins to update your table but if it would be faster remains to be seen.
Could you post the query plan so we can have a look at that
update dbo.TFIN_Stmt_Line_Item_Dtl set Stmt_Line_Item_Dtl_Desc = 'Changes from Baseline' from dbo.TFIN_Stmt_Line_Item_Dtl dtl inner join dbo.TFIN_Stmt_Line_Item li on li.tmt_Line_Item_Ref_Id = dtl.Stmt_Line_Item_Id inner join dbo.TFIN_Stmt_Line_Item_Type lit on lit.Stmt_Line_Item_Type_Id = li.Stmt_Line_Item_Type_Id where dtl.Stmt_Line_Item_Dtl_Desc='Increased Hours' and lit.Stmt_Line_Item_Desc like 'ABOX/RBOX Amendment 18 and 20'