在MySQL中同时输入多个数据?
以下是语法-
insert into yourTableName values(yourValue1,yourValue2,.....N), (yourValue1,yourValue2,.....N), (yourValue1,yourValue2,.....N), (yourValue1,yourValue2,.....N), . . . N
让我们创建一个表-
mysql> create table demo56 −> ( −> id int, −> first_name varchar(20), −> last_name varchar(20), −> age int −> );
借助insert命令将一些记录插入表中-
mysql> insert into demo56 values(1,'John','Smith',23), −> (2,'David','Miller',21), −> (3,'Chris','Brown',22), −> (4,'Carol','Taylor',20); Records: 4 Duplicates: 0 Warnings: 0
使用select语句显示表中的记录-
mysql> select *from demo56;
这将产生以下输出-
+------+------------+-----------+------+ | id | first_name | last_name | age | +------+------------+-----------+------+ | 1 | John | Smith | 23 | | 2 | David | Miller | 21 | | 3 | Chris | Brown | 22 | | 4 | Carol | Taylor | 20 | +------+------------+-----------+------+ 4 rows in set (0.00 sec)