Subject | Re: 2 inner joins on the same table |
---|---|
Author | Ricardo |
Post date | 2005-03-10T12:42:07Z |
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
message remains the same. Any other idea?
Thanks
wrote:
> At 06:21 PM 9/03/2005 +0000, you wrote:<dwilson@d...>
>
> >--- In firebird-support@yahoogroups.com, "Dan Wilson"
> >wrote:teams
> > > On 3/9/2005 at 5:55 PM Ricardo wrote:
> > >
> > > > I have a table Match in which each match has two teams. The
> >arethe
> > > > stored on the Team table. When I get one match, I need to get
> > > > names of both teams.optional,
> > > >
> > >
> > > assume table Team has two fields: id and name
> > > assume table Match has two fields: team1 and team2, which are
> >foreign key references to id in Team
> > >
> > > select team1, team2, t1.name, t2.name from Match
> > > inner join Team t1 on team1 = t1.id
> > > inner join Team t2 on team2 = t2.id;
> > >
> > > Is that what you want to do?
> > >
> > > HTH,
> > >
> > > Dan.
> >
> >Yes, but it doesn't work. I get the error:
> >
> >Invalid token.
> >Dynamic SQL Error.
> >SQL error code = -104.
> >Token unknown - line 6, char 1.
> >INNER.
>
> It doesn't mean INNER is not an allowed keyword (although it is
> since JOIN without LEFT, RIGHT or OUTER is an inner join bynature!). It's
> not a dialectal issue, either. It means something was missing inthe
> preceding clause - in this case, the table alias for Match.Good try, but it doesn't work. I don't know what's wrong. The error
>
> Fix it as follows:
>
> select m.team1, m.team2, t1.name, t2.name from Match m
> inner join Team t1 on m.team1 = t1.id
> inner join Team t2 on m.team2 = t2.id;
>
> ./heLen
message remains the same. Any other idea?
Thanks