Re: Joining 2 columns from the same table
PleegWat wrote:
> In article <1158753035.660362.86060@m7g2000cwm.googlegroups.c om>, Nicos
> says...
> > Hello,
> > i have a table (Matches) than have the columns listed below:
> > matchId, homeTeam, awayTeam, result
> >
> > I want to list all the teams DISTINCT both home and away teams.
> > How do i do that?
> >
> > Best regards,
> > Nicos
>
> Maybe:
>
> SELECT DISTINCT `Team`
> FROM (
> SELECT `homeTeam` AS `Team`
> FROM `Matches`
> UNION
> SELECT `awayTeam` AS `Team`
> FROM `Matches`)
> --
> PleegWat
That does the same as my ealier query as UNION keeps only distinct
values (as opposed to UNION ALL which keeps all values) |