Issue
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.
Solution
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.
Answered By - John Rotenstein Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.