Teradata update join syntax

oscilatingcretin picture oscilatingcretin · Feb 10, 2012 · Viewed 28.7k times · Source

I've tried a few examples I've seen on the internet, but I can't seem to figure them out. This is a Teradata database.

I have TableA that has CustomerId and DepartmentId.

I have TableB that also CustomerId and DepartmentId.

I know this structure is not practical, but this is a highly non-normalized database that we took over from an offshore development team and we have to work with what we have.

What I want to do is join TableA and TableB on the CustomerId then set the DepartmentId of TableB to what's in TableA. I would greatly appreciate the proper syntax.

Answer

Lenin Raj Rajasekaran picture Lenin Raj Rajasekaran · Feb 10, 2012
UPDATE A
FROM TableA A, TableB B
SET DepartmentId = B.DepartmentId
WHERE A.CustomerId = B.CustomerId