SQLite Aliases
Aliases
An alias gives a column or a table a temporary name. It only exists while the query runs.
An alias is made with the AS keyword:
AS is Optional
You can leave out AS, and the alias still works:
Aliases With a Space
If the alias contains a space, put it in double quotes. Double quotes are right here, because an alias is a name, not a text value:
Join Columns Together
In SQLite, || joins texts together. This example joins four columns into one column named Address:
Example
SELECT CustomerName,
Address || ', ' || PostalCode || ' ' || City
AS Address
FROM Customers;
Try it Yourself »
Alias for Tables
Table aliases make long queries shorter. This example selects the orders from the customer "Around the Horn":
Example
SELECT o.OrderID, o.OrderDate, c.CustomerName
FROM Customers AS c, Orders AS o
WHERE c.CustomerName = 'Around the Horn'
AND c.CustomerID = o.CustomerID;
Try it Yourself »