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.

No comments:

Post a Comment