vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Nicos wrote: > 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 Are you looking for something like: SELECT homeTeam FROM matches UNION SELECT awayTeam FROM tmatches |
| |||
| Nicos wrote: > 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 something like: SELECT DISTINCT (homeTeam, awayTeam), result FROM Matches; -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
| |||
| 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 Remove caps to reply |
| |||
| 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) |
| |||
| 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) |
| |||
| In article <1158826754.185026.146540@e3g2000cwe.googlegroups. com>, Captain Paralytic says... > > 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) Well, I knew the syntax, but I never actually used unions before. Didn't know it was distinct by default, assumed it wasn't since most stuff doesn't seem to be. -- PleegWat Remove caps to reply |
| ||||
| PleegWat wrote: > In article <1158826754.185026.146540@e3g2000cwe.googlegroups. com>, > Captain Paralytic says... > > > > 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) > > Well, I knew the syntax, but I never actually used unions before. Didn't > know it was distinct by default, assumed it wasn't since most stuff > doesn't seem to be. > -- > PleegWat That's the beauty of posting responses to other people's queries. You learn more when other's comment on your post. Admittedly some people correct others in a rather less than sympathetic manner, but the outcome of learning more still makes it worth it (IMHO). |