MySQL Insert Statement

MySQL INSERT statement adds new records into the table cells.

MySQL INSERT Syntax


Insert Values into Single Row

INSERT INTO table (First_Column, Second_Column,....Nth_Column) VALUES (value_1_for_First_Column, value_2_for_Second_Column,...,ValueN_for_Nth_Column)

 

Insert Values into Multiple Rows

INSERT INTO table (First_Column, Second_Column,....Nth_Column) VALUES (value_1_for_First_Column, value_2_for_Second_Column,...,ValueN_for_Nth_Column), (value_1_for_First_Column, value_2_for_Second_Column,...,ValueN_for_Nth_Column),...

Example

Table Products

ID Product Name Price £ Description
1 3D Glasses 14.49 High quality 3D glasses for 3D projectors.
2 Projector 400 HD and 3D ready Home teather projector.
3 Projector Screen 60 Perfect home teather experience with 90'' screen.

Inserting values to 4th row of the table above

mysql> INSERT INTO products(product_name, price, description) 
->VALUES ('Sound System', 800, 'High quality sound system.');

 

ID Product Name Price £ Description
1 3D Glasses 14.49 High quality 3D glasses for 3D projectors.
2 Projector 400 HD and 3D ready Home teather projector.
3 Projector Screen 60 Perfect home teather experience with 90'' screen.
4 Sound System 800
High quality sound system.