SQL INSERT INTO Statement

INSERT INTO statement is used to insert the records in table. We can insert records in table in two ways, the most commonly used way for insert is to specify both the column names and values.

All Columns

In this method there is no need to specify the column names in SQL query, however make sure the order of the values and columns.

Syntax
<?php  

    INSERT INTO table_name
	VALUES (value1, value2, value3, ...);

?>


Example
<?php  

    INSERT INTO Customers
	VALUES ('john', 'Michel john ', 'St 55', 'louse angelus', '4900', 'USA');

?>

Selective Columns

Syntax
<?php  

    INSERT INTO table_name (column1, column2, column3, ...)
	VALUES (value1, value2, value3, ...); 

?>


Example
<?php  

    INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
	VALUES ('john', 'Michel john ', 'St 55', 'louse angelus', '4900', 'USA');

?>