Ibrahim Azhar Armar Ibrahim Azhar Armar - 3 months ago 10
MySQL Question

how do i insert many values in a column in single query?

i have a mysql column called roles, i would like to insert many values at once instead of one value per query.

for example instead of making four queries to insert four values

INSERT INTO roles(roleName) VALUES('Admnistrator');
INSERT INTO roles(roleName) VALUES('SuperUser');
INSERT INTO roles(roleName) VALUES('Staff');
INSERT INTO roles(roleName) VALUES('Customers');


i would like it to make one single query. is it possible?

ace ace
Answer

You can do something like this

INSERT INTO 
         roles(roleName) 
  VALUES ('Admnistrator'), 
         ('SuperUser'), 
         ('Staff'), 
         ('Customers');