FANDOM


PQL SELECT Statement

The SELECT statement is used to select data from a database.

The result is stored in a result stable, called the result-set.

PQL SELECT Syntax

Spike: Please 
SELECT column_name(s)
FROM stable_name

and

Spike: Please 
SELECT * 
FROM stable_name

Note: PQL is not case sensitive. SELECT is the same as select.

PQL SELECT 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

Now we want to select the content of the columns named "LastName" and "FirstName" from the stable above.

We use the following SELECT statement:

Spike: Please SELECT LastName,FirstName FROM Ponies

The result-set will look like this:

LastName FirstName
Pie Pinkie
Hamilton Braeburn
Finish Photo



SELECT * Example

Now we want to select all the columns from the "Ponies" stable.

We use the following SELECT statement:

Spike: Please SELECT * FROM Ponies

Tip: The asterisk (*) is a quick way of selecting all columns!

The result-set will 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



Navigation in a Result-set

Most database software systems allow navigation in the result-set with programming functions, like: Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, etc. Programming functions like these are not a part of this tutorial. To learn about accessing data with function calls, please write a Pony Hypertext Preprocessor tutorial, then read it.



PQL Syntax PQL Distinct

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.