How can we insert data into a MySQL table?

MySQLMySQLi Database

For inserting data into a MySQL table we need to use INSERT INTO command. We must have to specify values for all the columns of the table in INSERT INTO command.


INSERT INTO table_name values(value1,value2,…)


Suppose we have a table named ‘Student’ with three columns ‘RollNo’, ‘Name’ and ‘Class’ then with the help of following query we can add new rows to the table −

mysql> INSERT INTO Student values(50,'Harshit',’’);
Query OK, 1 row affected (0.07 sec)

mysql> INSERT INTO Student values(56,'Amit',’’);
Query OK, 1 row affected (0.05 sec)

mysql> Select * from Student;
| RollNo  | Name        | Class     |
|  50     | Harshit     |    |  
|  56     |  Amit       |    |
2 rows in set (0.00 sec)
Published on 19-Feb-2018 17:27:17