[firebird-support] Re: Solution for a redundant join?

2012-10-24 Thread Jeff


--- In firebird-support@yahoogroups.com, "Leyne, Sean"  wrote:
 
> Use tables aliases to include multiple references to a single table.
> 
> 
> SELECT 
>   SCHEDULE.DATE_TIME, HomeTeam.TEAM, AwayTeam.Team
> FROM SCHEDULE 
>   LEFT JOIN TEAMS HomeTeam ON HomeTeam.PRIMARYKEY = SCHEDULE.HOME_TEAMID
>   LEFT JOIN TEAMS AwayTeam ON AwayTeam.PRIMARYKEY = SCHEDULE.AWAY_TEAMID
> 
> 
> Sean
>

Sean, aliases did the trick, thank you kindly!



Re: [firebird-support] Re: Solution for a redundant join?

2012-10-24 Thread Ann Harrison
On Wed, Oct 24, 2012 at 4:34 PM, Jeff  wrote:

>
> > Use tables aliases to include multiple references to a single table.
> >
> >
> > SELECT
> >   SCHEDULE.DATE_TIME, HomeTeam.TEAM, AwayTeam.Team
> > FROM SCHEDULE
> >   LEFT JOIN TEAMS HomeTeam ON HomeTeam.PRIMARYKEY = SCHEDULE.HOME_TEAMID
> >   LEFT JOIN TEAMS AwayTeam ON AwayTeam.PRIMARYKEY = SCHEDULE.AWAY_TEAMID
>
> Sean, aliases did the trick, thank you kindly!
>
>
Just out of curiosity, do you have any schedule records for which there are
not matching home teams and away teams?  If not, I would use two inner
joins rather than two outer joins.  That lets the optimizer do a better job
of planning the execution path.

Good luck,

Ann


[Non-text portions of this message have been removed]