If you really want to do this in a single SQL statement, one way to achieve this is to create an โafter deleteโ trigger on the source table that inserts the row into the target table. This way you can move the row from the source table to the target table by simply deleting it from the source table. Of course, this will only work if you want to insert into the goal table for each deletion in the source table.
DELIMITER $$ DROP TRIGGER IF EXISTS TR_A_DEL_SOURCE_TABLE $$ CREATE TRIGGER TR_A_DEL_SOURCE_TABLE AFTER DELETE ON SOURCE_TABLE FOR EACH ROW BEGIN INSERT IGNORE INTO TARGET_TABLE(id,val1,val2) VALUES(old.id,old.va1,old.val2); END $$ DELIMITER ;
So, to move the row with id 42 from the source table to the target table:
delete from source_table where id = 42;
source share