mysql move row between tables

后端 未结 7 1068
后悔当初
后悔当初 2020-12-14 19:06

I have 2 tables, table1 and table2.

I have a row in table1 and want to move it to table2 and remove it from table1. Basically, a cut+paste.

I am using php.

7条回答
  •  旧时难觅i
    2020-12-14 19:35

    You're going to need at least 2 queries:

    INSERT INTO table2 (column_name1, column_name2) SELECT column_name1, column_name2 FROM table 1 WHERE 
    
    DELETE FROM table1 WHERE 
    

    I see no shorter way of doing this using MySQL

提交回复
热议问题