SQL INSERT INTO Statement
$count++; if($count == 1) { include "../mobilemenu.php"; } if ($count == 2) { include "../sharemediasubfolder.php"; } ?>
INSERT INTO statement is used in SQL to insert a record into a Database table. The Syntax of INSERT INTO statement is as follows:
INSERT INTO table (column1, column2.... columnN) values (value1, value2.... valueN)
In case the set of values are equal to the number of columns, we need not specify the list of column names.Imagine we have table called CUSTOMER, with the following data:
FIRSTNAME
LASTNAME
AGE
COUNTRY
Rambo
Robert
25
Belgium
Mugambo
37
Norway
Nagashekar
Rao
47
India
Such values are known as NULL values.
Let us look at examples of SQL INSERT INTO.
Scenario 1: Insert a record into Customer table. Firstname: Karan, Lastname: Arjun, Age: 24, Country: Italy.
We can use a INSERT INTO statement as follows.
INSERT INTO CUSTOMER VALUES ('Karan', 'Arjun', 24, 'Italy')
Result:
1 Row inserted. Table contents:
FIRSTNAME
LASTNAME
AGE
COUNTRY
Rambo
Robert
25
Belgium
Mugambo
37
Norway
Nagashekar
Rao
47
India
Karan
Arjun
24
Italy
Scenario 2: Insert a record into Customer table. Firstname: Neo, Age: 24, Country: Germany.
We can use a INSERT INTO statement as follows.
INSERT INTO CUSTOMER(FIRSTNAME, AGE, COUNTRY) VALUES ('Neo', 22, 'Germany')
Result:
1 Row inserted. Table contents:
FIRSTNAME
LASTNAME
AGE
COUNTRY
Rambo
Robert
25
Belgium
Mugambo
37
Norway
Nagashekar
Rao
47
India
Karan
Arjun
24
Italy
Neo
22
Germany