I’m trying to process the following in one sql statement – I want to copy the number of records to the archive table and straight away remove the existing ones from the main table.
Something like:
INSERT INTO `table_archive`
SELECT * FROM `table_main`
WHERE `id` IN (1, 2, 3, 4)
REMOVE FROM `table_main` WHERE `id` IN (1, 2, 3, 4)
It’s basically like cutting and pasting records from one table to another.
Obviously the above statement is just what I want to achieve – any idea if it’s achievable at all and what sql statement would it be?
as mentioned you need to use several DML commands:
see: http://dev.mysql.com/doc/refman/5.0/en/commit.html