INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

T-SQL Hints and Tips

How-To Update Tables Using Inner Joins by MapMan
Posted: 23 May 02

You've gone through the trouble of creating a select statement that joins a couple of tables together and discovered that some data needs to be updated.  How can you do that when you've joined tables?

First, state that you're going to be performing an update...

UPDATE

Then join the tables that will meet the condition.

TABLEA AS A INNER JOIN TABLEB AS B ON A.F1=B.F1

Then state what's going to change.

SET A.X = 1, B.Y = 2

Then we add a WHERE clause.

WHERE A.Z =10

Tie it all together...

UPDATE TABLEA AS A INNER JOIN TABLEB AS B ON A.F1=B.F1
  SET A.X = 1, B.Y = 2 WHERE A.Z =10

Problem solved.

Good Luck,

MapMan


Assume nothing, question everything, be explicit not implicit, and you'll always be covered

Back to Microsoft SQL Server: Programming FAQ Index
Back to Microsoft SQL Server: Programming Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close