You would have to do another Update statement. You can only change 1 table at a time in an update statement. You could still use the 2 table joins, but it would have to be in a separate statement.
Main Topics
Browse All TopicsHi,
Here is my update statement:
Update Models
SET ModelNum = '123-TSTMODEL',
ModelDesc = 'GEN. ELEC. MODEL'
FROM Models a
left join companies b on a.ModelManfID = b.CompanyID
WHERE a.ModelID = 252767
My question is if I have b.CompName that need to be updated based on the two table
relationship and the ModelID.
How can I update the b.CompName to be included with my above SQL statement.
Thanks,
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
SET XACT_ABORT ON -- rollback transaction on any error
BEGIN TRAN
Update Models
SET ModelNum = '123-TSTMODEL',
ModelDesc = 'GEN. ELEC. MODEL'
FROM Models a
left join companies b on a.ModelManfID = b.CompanyID
WHERE a.ModelID = 252767
UPDATE c
SET c.CompanyName = 'My name'
FROM companies c
JOIN models a a.ModelManfID = c.CompanyID
WHERE a.ModelID = 252767 -- update all companies with modelManfId = 252767
COMMIT TRAN
PS. You don't need to join models here because you can make WHERE clause based only on companies fields (ModelManfID). If you have to filter by some fields in models table, the join would be usefull here.
Business Accounts
Answer for Membership
by: maradamPosted on 2008-01-24 at 06:56:55ID: 20733510
You just can't update two or more tables within one update statement. You need to write another one. All you can do to maintaing business integrity is to include both statements in a transaction.