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

后端 未结 3 807
花落未央
花落未央 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 04:55

    INSERT INTO your_table (ID, ISO3, TEXT) 
    SELECT ID, 'JPN', TEXT
    FROM your_table 
    WHERE ID IN ( list_of_ id's )
    

    If you want to change a value in one cell, just hard-type the value instead of selecting from table (like I did with 'JPN').

提交回复
热议问题