Reputation: 1845
I've a redshift table:
table t1 with cols -> a,b,c,d
table t2 with cols -> a,c,d
I need to update c,d values where t1.a = t2.a
t1 can have multiple rows with same a while t2 will have a single row for each a (a is unique in t2). Can I understand how can I update the values of t1.c, t1.d using t2.
Upvotes: 0
Views: 2247
Reputation: 269141
You'd probably use something like:
UPDATE t1
SET t1.c = t2.c,
t1.d = t2.d
FROM t2
WHERE t1.a = t2.a
See also: Examples of UPDATE statements - Amazon Redshift
The table mentioned after UPDATE
acts like it was included in the FROM
and the extra tables can be added via the FROM
, with joining via the WHERE
.
Upvotes: 3