November 12, 2009 at 11:09 am
i have 3 tables
First table
table1
AcctNo OfficerID Address
111 P343 test
222 blank test2
333 abcd
Table2
AcctNo producttypedesc
111 teast
222 tesdfst2
333 tesgsg
table3
AcctNo officerID producttypedesc
111 FADCDG test
333 98989hh test3
i want to update officerID in table 1 from table 3 based on acctno and producttypedesc to table2 from table 3 based on acctno
Please let me know how to do this
November 12, 2009 at 11:24 am
Two things.
First, based on the data provided, what is the expected output from the update?
Second, could you please show us what you have done so far to solve your problem?
November 12, 2009 at 12:05 pm
So you mean to say you want the 1st Table be line this after update?
table1
AcctNo OfficerID Address
111 FADCDG test
222 blank test2
333 98989hh
Then use this script
Update Table1 SET
OfficerID = table3.OfficerID
from table1
inner join table3
on table1.AcctNo = table3.AcctNo
Update Table2 SET
producttypedesc= table3.producttypedesc
from table2
inner join table3
on table2.AcctNo = table3.AcctNo
Blog -- LearnSQLWithBru
Join on Facebook Page Facebook.comLearnSQLWithBru
Twitter -- BruMedishetty
November 12, 2009 at 12:40 pm
Thanks Bru
that helped me.
i was trying to do subquery and it didnt work
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply