List:General Discussion« Previous MessageNext Message »
From:Eric Bergen Date:July 5 2004 5:02pm
Subject:Re: another left join question - multiple "left join" statements
View as plain text  
You only need to specify from tabel on the first table. Like this.

select 
 cattbl.name as cat, dogtbl.name as dog, birdtbl.name as bird
from dogtbl
left join cattbl on cattbl.id=dogtbl.catid
left join birdtbl on birdtbl.dogid=dogtbl.id;

-Eric

On Mon, 5 Jul 2004 09:28:02 -0700, bruce <bedouglas@stripped> wrote:
> my test tbls
> 
> cattbl     dogtbl         birdtbl
> name        name           name
> id -------> catid     ---> dogid
>              id   ----      id
> 
> so
>  dogtbl.catid = cattbl.id
>  birdtbl.dogid = dogtbl.id
> 
> my question is how i can use "left joins" to produce the results set with the names
> of all three cat/dog/bird...
> 
> i've tried various derivatives of the following...
> mysql> select cattbl.name as cat,
>     -> dogtbl.name as dog, birdtbl.name as bird
>     ->      from dogtbl
>     ->      left join cattbl on cattbl.id=dogtbl.catid
>     ->      from birdtbl
>     ->      left join dogtbl on birdtbl.dogid=dogtbl.id;
> 
> i keep getting an error complaining about the 2nd "from/left join"...
> 
> i know how to get the results using "where/and" logic... but i'm trying to get a
> better feel of the "left join" process...
> 
> after looking at mysql/google, i'm still missing something...
> 
> any comments/criticisms appreciated..
> 
> thanks
> 
> -bruce
> 
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
> 
>
Thread
mySQL LIMIT and ORDER BY Problem???Gary Mack4 Jul
  • Re: mySQL LIMIT and ORDER BY Problem???John Hicks5 Jul
    • basic question about joins....bruce5 Jul
      • Re: basic question about joins....Wesley Furgiuele5 Jul
      • Re: basic question about joins....John Hicks5 Jul
        • another left join question - multiple "left join" statementsbruce5 Jul
          • Re: another left join question - multiple "left join" statementsJohn Hicks5 Jul
          • Re: another left join question - multiple "left join" statementsEric Bergen5 Jul