我想在该特定表中添加新数据之前清除我的表

时间:2017-08-11 06:45:53

标签: php mysql

我想在该特定表格中添加新数据之前清除我的表格。

之后,在清除表之前,已经存在的数据必须移动到另一个表。

table1->Insert new data and move old data to table2

table2->old data of table1 + new data of table1

2 个答案:

答案 0 :(得分:0)

应该是:

  1. 将旧数据移至table2

  2. 删除table1中的数据

  3. 在table1中插入新数据

  4. 根据您列出的步骤,表1和表2之间没有任何区别。

答案 1 :(得分:0)

试试这个:

$query = "Insert into table_2 Select * from table_1";
mysql_query($query);
mysql_query("Truncate table table_1");