SQL INSERT INTO

It insert a new row in a table

SQL INSERT INTO Syntax

It can be used in two form

1) Without mentioning column names . In that case we must enter values for all fields .

INSERT INTO table_name VALUES (value1, value2.)

2) By mentioning column names and values

INSERT INTO table_name (column1, column2) VALUES (value1, value2)

MySQL Table – users

+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
|  2 | JS   |
|  3 | HTML |
|  4 | PHP  |
+—-+——+

Example

mysql> INSERT INTO users values(5,”AS”);
Query OK, 1 row affected (0.02 sec)

mysql> select * from users  ;
+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
|  2 | JS   |
|  3 | HTML |
|  4 | PHP  |
|  5 | AS   |
+—-+——+
5 rows in set (0.00 sec)