PinoyTech.org

CodeIgniter, Kohana, Mootools, jQuery and CSS

SQL Insert

The INSERT statement is commonly used to add a single row of data to a database tables. The INSERT syntax is as follows:

INSERT INTO 'table'(column1, column2)
VALUES ('field_value', 'field_value');

INSERT Example Usage

The Persons Table

ID First_Name Last_Name Gender Occupation
123 Fabian Rico Male Fireman
345 Martin Grant Male Fireman
223 Chloe Strange Female Secretary

In this example we would to add Chester Moreno to the database table.

INSERT INTO Persons (ID, First_Name, Last_Name, Gender, Occupation)
VALUES ('152', 'Chester', 'Moreno', 'Male', 'Web Designer');

With that statement, Persons would have another row inserted. The result would be:

ID First_Name Last_Name Gender Occupation
123 Fabian Salvador Male Fireman
345 Abigail Grant Female Fireman
223 Chloe Strange Female Secretary
152 Chester Moreno Male Web Designer