SQL - 将数据从 1 table 移动到范围内的另一个

SQL - move data from 1 table to another in a range

我有 1 table q3ept_content 有 8000 个条目。 我想将范围内 1 到 500 的数据移动到新的 table2

在table q3ept_content中我有很多列但是我有一个id列我可以移动所有500行..

请告诉我 SQL 查询

1 之间 500 移动到新 table .

这可以帮助您从 table range/limit/condition 和 INSERT 变成另一个 table。

INSERT INTO tbl_temp2 (id,column2,column3,column4)
  SELECT tbl_temp1.id,tbl_temp1.column2,tbl_temp1.column3,tbl_temp1.column4
FROM tbl_temp1 LIMIT 500;

查看更多 :https://dev.mysql.com/doc/refman/5.0/en/insert-select.html

INSERT INTO table2 (Col1, Col2, Col3)
       SELECT Col1, Col2, Col3
       FROM q3ept_content  WHERE id BETWEEN 1 AND 500;

或者如果您只想要 q3ept_content 的前 500 条记录:

INSERT INTO table2 (Col1, Col2, Col3)
       SELECT Col1, Col2, Col3
       FROM q3ept_content LIMIT 500;

Col1, Col2, Col3 - 您要移动的列

注意: 确保在 table2

中有 AUTO INCREMENT id 字段