I have a table name:: users with id and name in mysql, the id is primary key with auto increment and name is varchar(50) and now i have a bunch of unique names almost 70, how should i insert it in bulk, i know basic statements but i didn't found something best related to this problem
mysql> desc users;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(100) | YES | | NULL | |
+-------+--------------+------+-----+---------+----------------+
The MySQL docs says:
INSERT statements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of comma-separated column values, with lists enclosed within parentheses and separated by commas. Example:
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
Also you can use the Insert... Select... syntax:
INSERT INTO tbl_name (a,b,c)
SELECT a,b,c
FROM ...
Sorry man for me it was simple only insert into users (name) values ("name1"),("name2");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.