Insert Row into MySQL
How to Add or Insert Row into MySQL database table using INSERT query?
Explanation
INSERT STATEMENT :
INSERT query is used for insert a new row or data into an existing table.
The Insert syntax is
INSERT INTO tbl_name VALUES[(col_name,...)];
If the datatype is not mentioned it will consider NULL values.
The following insert statement will add the values like studid, name, marks, address and Phone number into the table student.
Example :
mysql> insert into student values(1, "steve", 100, "5th cross street", 2456987);
Query OK, 1 row affected (0.01 sec)
This is an example for simple insert query.
INSERT...SET STATEMENT :
The
INSERT...SET is also used to insert values the using the column name.
Syntax :
INSERT INTO tbl_name SET col_name = expr,.....;
Lets take the same values inserting into the table student.
Example :
mysql> insert into student set studid=1, name='steve', marks=100, address='5th cross street', phone=2456987;
Query OK, 1 row affected (0.03 sec)
This is an example for insert row into mysql table with INSERT ...SET Satement.we can use these insert statement to add a row into tables.