May 15, 2008 at 6:53 am
Hi All,
Yesterday i was asked a question regarding join and i told them that but after that the other question was can we use joins in update, i said no(with my knowledge). I want to know that i am correct or not.Please update me.
Thanks in advance,
Syed Sanaullah Khadri
DBA
May 15, 2008 at 6:59 am
Sure you can. It's actually a rather common operation in my shop.
UPDATE TableA
SET TableA.columnA=TableB.ColumnB
FROM TableA
INNER JOIN TableB ON TableA.ID=TableB.ID
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
May 16, 2008 at 12:11 am
Thanks Matt,
i have used joins may times but only to select not for update.
Will it work with insert and delete also.
May 16, 2008 at 1:43 am
[font="Verdana"]Obviously.
For Delete:
Delete From A Inner Join B On A.Id = B.Id
For Insert in different way like:
Insert Into A (col1, Col2)
Select B.Col1, C.Col2 From B Inner Join C On B.Id = C.Id
Mahesh
[/font]
MH-09-AM-8694
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply