SQL INSERT INTO Statement

0
154

sqltuts

A user can insert the data into a MySQL table using SQL INSERT INTO command. It can be done in two ways:-

1.) By using mysql> prompt

2.) By using any script like PHP.

Basic format to insert the data into the table:

In order to have insert string data types, it is important to keep the values into the double or single quote, for example- “value”.

Inserting Data from Command Prompt:

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

Example:

The following example will create 3 records into tutorials_table table:

Inserting Data Using PHP Script:

SQL INSERT INTO command into PHP function mysql_query() to insert data into a MySQL table.

Example:

The following example takes three different choices from the user and will insert them into MySQL table:

 

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.