Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: Multi Lookup Table Joins

From: Rob Wultsch <wultsch(at)gmail.com>
Date: Sun Sep 30 2007 - 11:54:05 EDT


Perhaps you want the ON syntax

SELECT x, y, z
FROM table t, lookupA a, lookupB b
WHERE t.aID = a.aID AND t.bID = b.bID

is equivalent to:

SELECT x, y, z
FROM table t
INNER JOIN lookupA a ON t.aID = a.aID
INNER JOIN lookupB b ON t.bID = b.bID

If you were to do:
SELECT x, y, z
FROM table t
INNER JOIN lookupA a USING(aID)
INNER JOIN lookupB b USING(bID)

that would be equivalent to
SELECT x, y, z
FROM table t
INNER JOIN lookupA a ON t.aID = a.aID
INNER JOIN lookupB b ON a.bID = b.bID

On 9/29/07, Chris W <2wsxdr5@cox.net> wrote:
> I often find that I have more than one column in a tale that is an
> integer ID used to join to a lookup table. If there is only one Join to
> do it is to do something like this....
>
> SELECT t.data, l.group
> FROM table t JOIN lookuptable l USING (groupID)
> WHERE whatever
>
> however if I need to join more than one that syntax wont work because
> the second join will be trying to join to the first lookup table no the
> main table. Is there a way around this or do I need to just do joins
> using this syntax....
> SELECT x, y, z
> FROM table t, lookupA la, lookupB lb
> WHERE t.aID = a.aID AND t.bID = b.bID
>
>
> --
> Chris W
> KE5GIX
>
> "Protect your digital freedom and privacy, eliminate DRM,
> learn more at http://www.defectivebydesign.org/what_is_drm"
>
> Gift Giving Made Easy
> Get the gifts you want &
> give the gifts they want
> One stop wish list for any gift,
> from anywhere, for any occasion!
> http://thewishzone.com
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=wultsch@gmail.com
>
>

-- 
Rob Wultsch
(480)223-2566
wultsch@gmail.com (email/google im)
wultsch (aim)
wultsch@hotmail.com (msn)

-- 
MySQL General Mailing List
For list archives: 
http://lists.mysql.com/mysql
To unsubscribe:    
http://lists.mysql.com/mysql?unsub=lists@pantek.com
Received on Sun Sep 30 11:54:56 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 10:12:59 EDT

Do you need help?X

Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library