FANDOM



The PQL UPDATE Statement

The UPDATE statement is used to update existing records in a stable.

PQL UPDATE Syntax

Spike: Please
UPDATE TABLE_NAME
SET column1=VALUE, column2=value2,...
WHERE some_column=some_value

Note: Notice the WHERE clause in the UPDATE syntax.
The WHERE clause specifies which record or records that should be updated.
If you omit the WHERE clause, all records will be updated!

PQL UPDATE Example

The "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
4 Macintosh Big Sweet Apple Acres Ponyville
5 MareDoWell Mysterious

Now we want to update the pony "MareDoWell, Mysterious" in the "Ponies" stable.

We use the following PQL statement:

Spike: Please UPDATE Ponies SET Address='Unknown', City='Ponyville' WHERE LastName='MareDoWell' AND FirstName='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 Unknown Ponyville



PQL UPDATE Warning

Be careful when updating records. If we had omitted the WHERE clause in the example above, like this:

Spike: Please UPDATE Ponies SET Address='Unknown', City='Ponyville'

The "Ponies" stable would have looked like this:

P_Id LastName FirstName Address City
1 Pie Pinkie Unknown Ponyville
2 Hamilton Braeburn Unknown Ponyville
3 Finish Photo Unknown Ponyville
4 Macintosh Big Unknown Ponyville
5 MareDoWell Mysterious Unknown Ponyville





PQL Insert PQL Delete

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.