首先,您缺少一个括号,在这种情况下您根本不需要使用该括号
将查询字符串更改为
Insert Into archived (select * from registrations WHERE id=$id)
^ ^
或只是
Insert Into archived select * from registrations WHERE id=$id
其次,INSERT不返回结果集,因此您不应使用mysql_fetch_array().
第三,如果您的意图不仅仅是移动数据,那么您还需要删除之后复制的行.
现在,您可以将其全部放入存储过程中
DELIMITER $$
CREATE PROCEDURE move_to_archive(IN _id INT)
BEGIN
START TRANSACTION;
INSERT INTO archived
SELECT *
FROM registrations
WHERE id = _id;
DELETE
FROM registrations
WHERE id = _id;
COMMIT;
END$$
DELIMITER ;
用法示例:
CALL move_to_archive(2);