Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Update Table with value from another table - help

$
0
0
Hi looking for some advice.

Basically i have 2 tables are joined together by common field.

I want to update table 1 with the value in table 2.

SELECT a.COLUMN1, b.COLUMN1, a.COLUMN2, b.COLUMN2
FROM TABLE1 a, TABLE2 b
WHERE a.COLUMN1 = b.COLUMN1

So in the above COLUMN1 is the JOIN to both tables.

Now COLUMN2 on TABLE2 has a value updated. I simply want to update TABLE1.COLUMN2 to the value held in TABLE2.COLUMN2 for the same COLUMN1 id.

In my head the following logic i would have thought worked but it doesn't and looking for help with the syntax please.

UDPATE TABLE1 a
SET a.COLUMN2 = b.COLUMN2
FROM TABLE1 a, TABLE2 b
WHERE a.COLUMN1 = b.COLUMN1

However, the above SQL does not work! Be grateful for some advice.

Viewing all articles
Browse latest Browse all 13329

Trending Articles