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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 UPDATE statement with multiple tables

Author  Topic 

Veritas5
Starting Member

6 Posts

Posted - 2009-08-05 : 17:00:09
Hi guys!

I've got another tricky question for you (Well, I don't have much experience yet, so that would be tricky for me).

I've got those 2 drivers tables. One of those tables is our main table, where all the data on our drivers are inserted. My second table would be a secondary table only useful for a small application I'm currently writting. If I want to update 1 field in my secondary table for every driver (In this case it would be the drivers Status) based on the drivers status in my main table, how would I create my query, considering only 1 table may be declared in an Update statement? Thanks!!

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-05 : 17:14:43
update t1
set status=t2.status
from table1 t1
join table2 t2 on t1.id=t2.id


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Veritas5
Starting Member

6 Posts

Posted - 2009-08-06 : 10:36:30
Thanks a lot! By the way, I'm working on a project in a solo team. Being by myself, I really appreciate all the help I can from sites such as this one!
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-06 : 11:50:50
you are welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -