Wednesday, June 2, 2010

Update Query with a JOIN Statement

I found something useful when I am trying to update columns in a master table (tbl1) from data in a temp table (tbl2). These updates can be done by making a query to update a table by doing INNER JOIN.

Below is the example of a joined update query:

UPDATE tbl1
SET field_name = B.field_name
FROM tbl1 A
INNER JOIN tbl2 B
ON A.ID = B.ID



Hope this helps.

0 comments:

 

Get paid for your opinions! Click on the banner above to join Planet Pulse. Its totally free to sign up, and you can earn UNLIMITED. Find out more by visiting PLANET PULSE.
Sign up for PayPal and start accepting credit card payments instantly. http://www.emailcashpro.com
July Code Blog Copyright © 2010 Blogger Template Designed by Bie Blogger Template