Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 update probs...

Author  Topic 

raaj
Posting Yak Master

129 Posts

Posted - 2008-02-13 : 15:53:05
Hello...
I am stuck with update statement...
I am having 3 tables abc,def and xyz...
i want to update column1 of abc with column2 of def values (here the probs is i dont have any common fields between them)
i am having common values between def(column10) and xyz(column10_new)
so i am using inner join something like below....

but this looks like wrong to me...bcoz when i do this (only select):
select column2 FROM def inner join xyz on def. column10 = xyz. column10_new
i am getting different as compared to the update below....

UPDATE abc
SET column1 = column2 FROM def inner join xyz
on def. column10 = xyz. column10_new

can anyone suggest how to solve this update???
Thanks

CoolEJ
Starting Member

7 Posts

Posted - 2008-02-13 : 16:09:35
your table must first have some relationship. abc is disconnected from the other two tables. --- No relation at all. Either you create a reltationship between abc and def or abc and xyz.
Without relationship, the column will just be placed in abc indiscriminately.
Go to Top of Page

jdaman
Constraint Violating Yak Guru

354 Posts

Posted - 2008-02-13 : 16:34:58
How are you ordering your tables? How do you know that column2 from table def is what you want in column1 in table abc?
Can you provide some sample data?
Go to Top of Page
   

- Advertisement -