Netezza UPDATE from one table to another

Ram picture Ram · Aug 6, 2014 · Viewed 26.5k times · Source

This is my query that does not work in Netezza:

UPDATE TABLE1 A
SET A.COL1= (SELECT DISTINCT B.COL1 FROM TABLE2 B WHERE B.ID= A.ID AND B.DeptID=104)
WHERE A.DeptID=3

How do I re-write this query? Please help.

Answer

Donal picture Donal · Aug 6, 2014
UPDATE TABLE1 A
SET A.COL1 = B.COL1
FROM TABLE2 B
WHERE
A.ID = B.ID AND 
A.DeptID = 3 AND 
B.DeptID = 104;