»  Home  »  Programming  »  Database Joins
Database Joins
By Chris Smith | Published 03/8/2006 | Programming | Rating: ratingfullratingfullratingfullratingfullratingfull Unrated |
Table Aliases

Another thing we can do to make this easier is to use a table alias. This is a "shortcut" to make our queries easier to read.

SELECT * FROM newsitem n INNTER JOIN authors a ON n.authorid=a.authorid;

We use "n" instead of "newsitem" and "a" instead of "authors". In this example we don't see much difference but if we selectively pick out our fields:

SELECT n.newsid, n.newstitle, n.newscontent, a.username, a.firstname, a.lastname FROM newsitem n INNER JOIN authors a ON n.authorid=a.authorid;

We can quickly see which field comes from which table and this saves us typing the whole table name!

In this particular case there's no real benefit from using table aliases, but try joining 3-4 tables together and you'll see a lot of use for it.

There you have it! Table joins and table aliases all in one go!
Pages: « Back  1 2 3 4  Next » 

Article Series

This article is part 4 of a 4 part series. Other articles in this series are shown below:
  1. An Introduction to Databases
  2. An Introduction to Database Variable Types
  3. Introduction to Database Indexes
  4. Database Joins



1 Response to "Database Joins"


 
mulugeta Rating: ratingfullratingfullratingfullratingfullratingfull Unrated
said this on 18 Mar 2006 2:10:44 PM CDT
It is good to achieve database education.



Rate this article and leave a reply:
1 2 3 4 5
Poor Excellent
Your Name *: Email (private) *: Website:
Please copy the characters from the image below into the text field below. Doing this helps us prevent automated submissions.
Security Code: img

Web designers: Learn how to attract more clients and profit like the big guys. Subscribe to our newsletter.