MySQL – Insert Row to Table

To insert a row or record into a table in MySQL, use SQL INSERT statement.

In this tutorial, we will learn the syntax of SQL INSERT statement to insert a row into MySQL Table, with examples.

Syntax – Insert Row into Table

The following is a simple syntax of INSERT statement to insert a row into table with two columns.

</>
Copy
INSERT INTO table_name (column_1_name, column_2_name)
	VALUES (column_1_value, column_2_value);

where

  • table_name is the table name into which we insert the row/record.
  • column_1_name, column_2_name, etc., are the names of columns present in the table.
  • column_1_value, column_2_value, etc., are the values in the record for the respective columns.

If there are more columns in the table, specify the column names and corresponding values in the query.

Example

In the following example, we will consider a table students and insert a row into this table.

SQL Query

</>
Copy
INSERT INTO students (name, rollno)
	VALUES ('Arjun', 14);

“students” Table

name	rollno
Arjun	14

Now, let us insert another row into this table.

SQL Query

</>
Copy
INSERT INTO students (name, rollno)
	VALUES ('Manish', 15);

“students” Table

name	rollno
Arjun	14
Manish	15