Using Table Aliases

In many SQL dialects, you can give table names aliases to save typing. Assign an alias in the table list by giving the alias after the table name, like this:

SQL
select p.pub_id, p.pub_name
from publishers p
					

The p in front of each of the column names in the SELECT list acts as a substitute for the full table name (publishers). This query is equivalent to

SQL
select publishers.pub_id, publishers.pub_name
from publishers

You can't combine the two naming conventions. Once you assign an alias, you must use the alias or no qualifier—alternately using the alias and the full table name in a given query isn't allowed because the alias actually substitutes for the table or view name during the query. In effect, the table name does ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.