Want to run Update in Teradata but with Inner joins

47 views Asked by At

I want to update a column named 'FLAG' and set its value as C when the records from two different tables have a match on a few conditions. Please see the below sample of what I'm trying to achieve in Teradata.

UPDATE DB.TABLENAME SET FLAG = 'C'
WHERE DB.TABLENAME A INNER JOIN DB2.TABLENAME2 B 
ON A.POLICY_NUMBER = SUBSTR(B.POLICY_NUMBER,5,8) AND
A.IDENTIFIER = B.IDENTIFIER AND A.NUMBER = B.NUMBER;

I'm sort of new to teradata and not able to figure out a way to do this.

I've tried this:

UPDATE A
FROM DB.TABLENAME A, DB2.TABLENAME2 B 
SET FLAG = 'C'
WHERE A.POLICY_NUMBER = SUBSTR(B.POLICY_NUMBER,5,8) 
AND A.IDENTIFIER = B.IDENTIFIER 
AND A.NUMBER = B.NUMBER;

But this gives me error as "Target row updated by multiple source rows".

0

There are 0 answers