Update a table with a query

I would like to update complete rows in a table base on a query simular to an insert into function.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Patrick MatthewsCommented:
UPDATE and INSERT have very different syntaxes.  Also, SQL Server and Access use very different UPDATE syntaxes.

1) Which DB platform will this run on?

2) Can you elaborate your request with an example?
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
you can use some query like

Update tbl1
      set a = 'a',
            b = 'b'
From tbl2
Where tbl1.a=tbl2.a
And tbl1.b=tbl2.b

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HainKurtSr. System AnalystCommented:
try this:

Update t1 set
  c = t2.c,
  d = t2.d,
  x = t2.x
From table1 t1 left join tbl2 t2 on t1.a=t2.a And t1.b=t2.b
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you might want to read this article: update with join:
You can update mutliple rows at at Time

Update Table1
Set ColumnName = 'XYZ', ---1st Method
  ColumnName = T2.Title -- 2nd Method,
From Table1 as T1
Join Table2 as T2 On T1.Id = T2.ColumnId
Where T1.ColumnName1 > 0

whatever conditions in where clause you can add............
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.