mysql 数据插入insert
mysql> select * from user; +------+----------+-----------+ | id | name | address | +------+----------+-----------+ | 1 | xiaoming | beijing | | 2 | xiaobai | shandong | | 3 | xiaohong | suzhou | | 4 | xiaohei | changchun | +------+----------+-----------+ 4 rows in set (0.00 sec) mysql> insert user(id,name,address) values(5,"xiaoli","dongjing"),(6,"xiaohuang","meiguo"); Query OK, 2 rows affected (0.01 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> insert user(id,name,address) select id,name,address from user where id=1; Query OK, 1 row affected (0.01 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> select * from user; +------+-----------+-----------+ | id | name | address | +------+-----------+-----------+ | 1 | xiaoming | beijing | | 2 | xiaobai | shandong | | 3 | xiaohong | suzhou | | 4 | xiaohei | changchun | | 5 | xiaoli | dongjing | | 6 | xiaohuang | meiguo | | 1 | xiaoming | beijing | +------+-----------+-----------+ 7 rows in set (0.00 sec)
mysql> insert into user(id,name,address) select id,name,address from user where id=1; Query OK, 2 rows affected (0.01 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> select * from user; +------+-----------+-----------+ | id | name | address | +------+-----------+-----------+ | 1 | xiaoming | beijing | | 2 | xiaobai | shandong | | 3 | xiaohong | suzhou | | 4 | xiaohei | changchun | | 5 | xiaoli | dongjing | | 6 | xiaohuang | meiguo | | 1 | xiaoming | beijing | | 1 | xiaoming | beijing | | 1 | xiaoming | beijing | +------+-----------+-----------+ 9 rows in set (0.00 sec)