Dhanraj
Dhanraj

Reputation: 1302

Get Storing updated rows and previous rows as well

Let's suppose I have table as :

column_1 | column_2 | column_3 | column_4


  abc        12         23          34

  abc        01         12          45

I am looking for query something like

insert into table(column_1,column_2,column_3,column_4) values(List of updated rows i.e select (do some logic here of changing value of column_1) from where column_1='abc')

Output should be as :-

column_1 | column_2 | column_3 | column_4


  abc        12         23          34

  abc        01         12          45

  xyz        12         23          34

  xyz        01         12          45

Upvotes: 1

Views: 44

Answers (1)

AntKoki
AntKoki

Reputation: 81

You can do it with another select from you insert. it not necessary to use insert into ... (...) values(..). You can use select as well as your value.

insert into table(column1,column2,column3,column4)
select 'xyz' as column1,column2,column3,column4 
from table
where column1 = 'abc'

Upvotes: 3

Related Questions