Using Aliases in the FROM Clause Table/View List
You can assign each table (or view—see Chapter 9) an alias (an abbreviation for the full table name) in the FROM clause table list, in order to make join queries
Easier to type
More readable
Assigning an alias to each table name is particularly helpful when you join on identically named columns, which have to be qualified with the table name each time they're used. Aliases can be letters or numbers in any combination; most people make them short and easy to remember.
Here's how you could use aliases in a query to find authors who live in the same city as some publisher:
SQL | SQL |
---|---|
select au_lname, au_fname select au_lname , au_fname from authors a, publishers p from authors a join publishers p where ... |
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.