日期:2014-05-16 浏览次数:20821 次
insert into A(C1,C2) select * from (select C1,C2 from B limit 10) r
------解决方案--------------------
INSERT INTO A SELECT * FROM (SELECT C1,C2 FROM B limit 10)t;
------解决方案--------------------
mysql> select * from tb_1;
+------+--------+----------+
| id | userid | friendid |
+------+--------+----------+
| 0 | 1 | 3 |
| 1 | 1 | 4 |
| 2 | 2 | 3 |
| 3 | 2 | 6 |
| 4 | 3 | 5 |
| 5 | 3 | 6 |
| 6 | 4 | 5 |
| 7 | 4 | 2 |
| 8 | 5 | 2 |
| 9 | 5 | 7 |
| 10 | 6 | 7 |
| 11 | 6 | 8 |
+------+--------+----------+
12 rows in set (0.04 sec)
mysql> create table tb_2 like tb_1;
Query OK, 0 rows affected (0.18 sec)
mysql> insert into tb_2 select * from tb_1 limit 5;
Query OK, 5 rows affected (0.05 sec)
Records: 5 Duplicates: 0 Warnings: 0
我这个是可以的。