With SQL, an alias name can be given to a table or to a column.
You can give a table or a column another name by using an alias. This can be
a good thing to do if you have very long or complex table names or column names.
An alias name could be anything, but usually it is short.
SQL Alias Syntax for Tables
SQL Alias Syntax for Columns
SELECT column_name AS alias_name
Assume we have a table
called "Persons" and another table called "Product_Orders". We will give the
table aliases of "p" an "po" respectively.
Now we want to list all the orders that "Ola Hansen" is responsible for.
the following SELECT
SELECT po.OrderID, p.LastName, p.FirstName
FROM Persons AS p,
Product_Orders AS po
The same SELECT
statement without aliases:
SELECT Product_Orders.OrderID, Persons.LastName, Persons.FirstName
As you'll see from the two SELECT statements above; aliases can make queries easier to
both write and to read.
The Altova MissionKit is a suite of intelligent XML tools, including:
XMLSpy® – industry-leading XML editor
- Support for all XML-based technologies
- Graphical editing views, powerful debuggers, code generation, & more
MapForce® – graphical data mapping tool
- Drag-and-drop data conversion with code generation
- Support for XML, DBs, EDI, Excel® 2007, text, Web services
StyleVision® – visual stylesheet designer
- Drag-and-drop stylesheet design for XML & databases
- Output to HTML, PDF, RTF, Word 2007, & more
Try before you buy with a free fully functional 30-day trial
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).