Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update

Status
Not open for further replies.

rekhatr10

Programmer
Apr 2, 2004
67
US
Hi everyone

How do I update 2 table at the same time? I have to move records from 2 table to a new acct # in the same table.

The fileds are

Table1 Table2
Acct Acct
Docid docid
idsubtype idsubtype
revvalue
userid

Based on acct number I have to change the the acct number from 1 to 2 and the revvalue should be 'R' for reviwed.

I was using
Update set account = 2 where account =1 and then go the table 2 join them on docid and idsubtype and used the folowing update sql statment
update set account = 2 where images.account = 2 and review.account = 1 it errored out.
Any suggestions would be helpful.

Thank you
Rekha

 

Your update statement is missing the join between the tables. For clarity, you should consider spelling out the fields as table.field.

Therefore - your update statement should look something like...

UPDATE table1
SET t1.field = 1
FROM table1 t1, table2 t2
WHERE t1.field2 = t2.field3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top