0

I have a table and I want to insert a new row that is exactly the same as one row EXCEPT with one column value different.

col1 col2 col3
joe  ben  sam

My desired output for the new row being added would be

col1 col2 col3
bob  ben  sam
joe  ben  sam

As you can see the original column is still there but we added a new row with the first value being changed from joe to bob.

Any ideas on the most elegant way to do this maybe without hard coding? I was thinking maybe an insert based on a select * where condition but not sure. Any tips would be greatly appreciated. Thank you!

codingInMyBasement
  • 728
  • 1
  • 6
  • 20
  • 1
    Does this answer your question? [INSERT INTO (SELECT & VALUES) TOGETHER](https://stackoverflow.com/questions/24244563/insert-into-select-values-together) – devlin carnate Oct 28 '21 at 21:13

1 Answers1

2

You can do:

insert into t (col1, col2, col3) select 'joe', col2, col3 from t
The Impaler
  • 45,731
  • 9
  • 39
  • 76