I want to update multiple columns in same update statement with one column depends upon another new column new value.
Example:
Sample Data: col1
and col2
is the column names and test_update
is the table name.
SELECT * FROM test_update;
col1 col2
col-1 col-2
col-1 col-2
col-1 col-2
update test_update set col1 = 'new', col2=col1||'-new';
SELECT * FROM test_update;
col1 col2
new col-1-new
new col-1-new
new col-1-new
What I need to achieve is col2
is updated as new-new as we updated value of col1
is new.
I think may be its not possible in one SQL statement. If possible How can we do that, If its not What is best way of handling this problem in Data Warehouse environment, like execute multiple update 1st on col1
and then on col2
or any other.
Hoping my question is clear.
question from:
https://stackoverflow.com/questions/65559570/how-to-update-multiple-columns-in-same-update-statement-with-one-column-depends 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…