PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, October 24, 2022

[FIXED] How to update redshift table (t1) from another table (t2)?

 October 24, 2022     amazon-redshift, amazon-web-services, sql-update     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing