假设我有一张桌子X和桌子Y. 我想删除表X中的行,我想将删除的行发送到表Y.我该怎么做?有人可以帮帮我吗。 :(非常感谢。
答案 0 :(得分:0)
假设表X& Y是确切的结构
首先:
calculateAndDisplayRoute()
然后:
insert into tableY select * from tableX where condition;
答案 1 :(得分:0)
这可能会对你有所帮助
mysql> create table X(id int)
-> ;
Query OK, 0 rows affected (0.51 sec)
mysql> create table Y(id int)
-> ;
Query OK, 0 rows affected (0.34 sec)
mysql> delimiter |
mysql> create trigger on_delete before delete on X for each row begin
insert into Y set id = OLD.id;
end ;
Query OK, 0 rows affected (0.06 sec)
mysql> insert into x (1),(2);
mysql> delete from X;
mysql> select * from Y;
+------+
| id |
+------+
| 1 |
| 2 |
+------+
2 rows in set (0.00 sec)
你可以用mysql trigger.more reference learn about trigger
来做到这一点