可以,只要你的表是完全一樣的字段數相匹配的數據類型使用insert into select...
語法年。
我只是跑下面作爲一個例子,爲您展現你的語法:
mysql> use test
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> create table test1 (id int(2), varry varchar(3));
Query OK, 0 rows affected (0.08 sec)
mysql> create table test2 (id int(2), barry varchar(3));
Query OK, 0 rows affected (0.05 sec)
mysql> insert into test2 values(1,'aaa');
Query OK, 1 row affected (0.00 sec)
mysql> select * from test1;
Empty set (0.00 sec)
mysql> insert into test1 (select * from test2);
Query OK, 1 row affected (0.06 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> select * from test1;
+------+-------+
| id | varry |
+------+-------+
| 1 | aaa |
+------+-------+
1 row in set (0.00 sec)
mysql> alter table test2 add column third int(1);
Query OK, 1 row affected (0.06 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> update test2 set barry='ccc';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> insert into test1 (select * from test2);
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql>
你提的問題是非常清楚 - 爲什麼會在您指定沒有標準的更新工作,以匹配記錄。你是什麼意思的'64結構' –
@阿德里安:可能意味着64場。這將是一個單調乏味的列表,但通常這意味着OP是懶惰的 –
@MarcB永遠不會! OP總是提供我們需要的所有信息來回答他們的問題;-) –