View Single Post
  #2 (permalink)  
Old July 22nd, 2010, 06:36 PM
Old Pedant Old Pedant is offline
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Those are just "aliases". A far *BETTER* way to write that would be:
Code:
   $query = 'SELECT 
       c.alias, c.real_name, c.alignment, 
       l.address, z.city, z.state, z.zipcode_id 
       FROM 
           comic_character AS c, comic_lair AS l, comic_zipcode AS z 
       WHERE 
           z.zipcode_id = l.zipcode_id AND 
           c.lair_id = l.lair_id AND 
           c.character_id = '. $character_id; 
So that the AS clearly says "this is an alias I am using."

That is, those are "shortcut" names given to those tables, for convenience.


That code is 100% equivalent to
Code:
   $query = 'SELECT 
       comic_character.alias, comic_character.real_name, comic_character.alignment, 
       comic_lair.address, comic_zipcode.city, comic_zipcode.state, comic_zipcode.zipcode_id
       FROM comic_character, comic_lair, comic_zipcode 
       WHERE 
           comic_zipcode.zipcode_id = comic_lair.zipcode_id AND 
           comic_character.lair_id = comic_lair.lair_id AND 
           comic_character.character_id = ' . $character_id; 
You see? It makes the code easier to read, but other than that it has *ZERO* impact on the query.
Reply With Quote
The Following User Says Thank You to Old Pedant For This Useful Post:
DMatt (July 26th, 2010)