Subject Re: 2 inner joins on the same table
Author Ricardo
--- In firebird-support@yahoogroups.com, "Dan Wilson" <dwilson@d...>
wrote:
> On 3/9/2005 at 5:55 PM Ricardo wrote:
>
> > I have a table Match in which each match has two teams. The teams
are
> > stored on the Team table. When I get one match, I need to get the
> > names of both teams.
> >
>
> 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.