FANDOM



PQL Alias

With PQL, an alias name can be given to a stable or to a column. You can give a stable or a column another name by using an alias. This can be a good thing to do if you have very long or complex stable names or column names.

An alias name could be anything, but usually it is short.

PQL Alias Syntax for Stables

Spike: Please
SELECT column_name(s)
FROM stable_name
AS alias_name
PQL Alias Syntax FOR COLUMNS
SELECT column_name AS alias_name
FROM stable_name



Alias Example

Assume we have a stable called "Ponies" and another stable called "Cupcake_Orders". We will give the stable aliases of "p" and "co" respectively.
Now we want to list all the orders that "Pinkie Pie" is responsible for.

We use the following SELECT statement:

Spike: Please SELECT po.OrderID, p.LastName, p.FirstName FROM Ponies AS p, Cupcake_Orders AS co WHERE p.LastName='Pie' AND p.FirstName='Pinkie'

The same SELECT statement without aliases:

Spike: Please SELECT Cupcake_Orders.OrderID, Ponies.LastName, Ponies.FirstName FROM Ponies, Cupcake_Orders WHERE Ponies.LastName='Pie' AND Ponies.FirstName='Pinkie'

As you'll see from the two SELECT statements above; aliases can make queries easier both to write and to read.



PQL Between PQL Joins

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.