insert data query mysqli. Insert data into MySQL table, you will need to use SQL INSERT INTO command. You can use the mysql> prompt or by using a PHP script like any data inserted into the MySQL tables.

syntax:

Here is the INSERT INTO command to insert data into MySQL tables generic SQL syntax:

INSERT INTO table_name ( field1, field2,…fieldN )
VALUES
( value1, value2,…valueN );

To insert the string data type, you need to keep all of the value of double or single quotes, for example: – “values.”

Insert data from the command prompt:

This will use SQL INSERT INTO command to insert data into MySQL table tutorials_tbl.

example:

The following example will create three records to tutorials_tbl table:

root@host# mysql -u root -p password;
Enter password:*******
mysql> use TUTORIALS;
Database changed
mysql> INSERT INTO tutorials_tbl
->(tutorial_title, tutorial_author, submission_date)
->VALUES
->(“Learn PHP”, “John Poul”, NOW());
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO tutorials_tbl
->(tutorial_title, tutorial_author, submission_date)
->VALUES
->(“Learn MySQL”, “Abdul S”, NOW());
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO tutorials_tbl
->(tutorial_title, tutorial_author, submission_date)
->VALUES
->(“JAVA Tutorial”, “Sanjay”, ‘2007-05-06’);
Query OK, 1 row affected (0.01 sec)
mysql>

Note: Please note that all the arrow symbol (->) is not part of the SQL command; they represent a new line, they will be automatically prompted by the MySQL simultaneously press the Enter key at the end of each line did not give a command to create a semicolon .

In the above example, it does not provide tutorial_id because when you create a table, we have given this field AUTO_INCREMENT option. So MySQL need to take care of these ID’s automatically inserted. Here, n () is a MySQL function that returns the current date and time.