Inserting multiple rows in MySQL Table in Single Statement - MySQL Developer Tutorial

Inserting multiple rows in MySQL Table in Single Statement 

If you need to insert multiple rows of data into MySQL Table, you can use below syntax.

insert into TableName
Values (ValueForColumn1,ValueforColumn2,....),

Example : 

In below example, we are creating customer table and then insert multiple rows into customer table by using single insert statement.

create customer table syntax:

CREATE TABLE `customer` (
  `idcustomer` int(11) NOT NULL auto_increment,
  `firstname` varchar(50)  NULL,
  `lastname` varchar(30)  NULL,
  `age` int(11) DEFAULT NULL,
  `phonenumber` char(11) DEFAULT NULL,
  `dob` date DEFAULT NULL,
  `gender` char(1) NOT NULL,
  Constraint pk_idcustomer Primary key (idcustomer)

) ;

Insert multiple rows in MySQL Table.

insert into customer

Insert Multiple records in MySQL table in single Insert Statement - MySQL Tutorial

No comments:

Post a Comment