FANDOM



The PQL INSERT INTO Statement

The INSERT INTO statement is used to insert a new row in a stable.

PQL INSERT INTO Syntax

It is possible to write the INSERT INTO statement in two forms.

The first form doesn't specify the column names where the data will be inserted, only their values:

Spike: Please
INSERT INTO stable_name
VALUES (value1, value2, value3,...)

The second form specifies both the column names and the values to be inserted:

Spike: Please
INSERT INTO stable_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)



PQL INSERT INTO Example

We have the following "Ponies" stable:

P_Id LastName FirstName Address City
1 Pie Pinkie Sugarcube Corner Ponyville
2 Hamilton Braeburn Braeburn Orchard Appleloosa
3 Finish Photo Biba Boutique Canterlot

Now we want to insert a new row in the "Ponies" stable.

We use the following PQL statement:

Spike: Please INSERT INTO Ponies VALUES (4,'Macintosh', 'Big', 'Sweet Apple Acres', 'Ponyville')


The "Ponies" stable will now look like this:

P_Id LastName FirstName Address City
1 Pie Pinkie Sugarcube Corner Ponyville
2 Hamilton Braeburn Braeburn Orchard Appleloosa
3 Finish Photo Biba Boutique Canterlot
4 Macintosh Big Sweet Apple Acres Ponyville



Insert Data Only in Specified Columns

It is also possible to only add data in specific columns.

The following PQL statement will add a new row, but only add data in the "P_Id", "LastName" and the "FirstName" columns:

Spike: Please INSERT INTO Ponies (P_Id, LastName, FirstName) VALUES (5, 'MareDoWell', 'Mysterious')


The "Ponies" stable will now look like this:

P_Id LastName FirstName Address City
1 Pie Pinkie Sugarcube Corner Ponyville
2 Hamilton Braeburn Braeburn Orchard Appleloosa
3 Finish Photo Biba Boutique Canterlot
4 Macintosh Big Sweet Apple Acres Ponyville
5 MareDoWell Mysterious





PQL Order By PQL Update

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.