MySQL INSERT INTO

Last Updated: March 15, 2022

INSERT INTO is used to insert data into the table

INSERT INTO Syntax

There are two ways you can use INSERT INTO

1 Specifying column names and values

Syntax

INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
INSERT INTO employee (name,age,salary) VALUES ("John Lee",42,89000)

3 Without specifying column names

You are going to insert data to all columns in the table. The order of the value should be matched with the order of the columns in the table.

Syntax

INSERT INTO table_name
VALUES (value1, value2, value3, ...);

Assume that the employee’s table has 3 columns

INSERT INTO employee VALUES ("John Lee",42,89000)

Related

Use INSERT SELECT to copy data from one table to another table

Test