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
我这个是可以的。
欢迎大家阅读《mysql临时表插入数据有关问题》,跪求各位点评,by 搞代码
原创文章,转载请注明: 转载自搞代码
微信 赏一包辣条吧~
支付宝 赏一听可乐吧~