mySql copy rows into same table with key value changed (not overwriting existing)

后端 未结 3 824
花落未央
花落未央 2021-01-04 04:28

How do I copy a selection of rows from a mySql table and insert with just the key value changed. Can I do a select and insert in same query?

To be precise, what I wa

3条回答
  •  爱一瞬间的悲伤
    2021-01-04 05:05

    you can do

    insert into your_table (SELECT field1, field2,(changed_value_for_field3) as field3 FROM your_table where your_condition);
    

提交回复
热议问题