Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Impossible SQL query?

Status
Not open for further replies.

woodpd

Programmer
Jun 20, 2002
10
AU
Dear people,

I am tearing my hair out trying to write an SQL statement to do the following:

In Table "Team" amongst other things I have a "TeamID" and a "TeamName". In Table "Match" amongst other things I have a "HomeTeamID" and an "AwayTeamID" that correspond to those in Table "Team".

In my query, I am trying to extract various fields from "Match" along with the related "TeamName" for "HomeTeamID" AND "AwayTeamID". I can retrieve either one of the team names easily using a join. However to collect both seems impossible without getting repeating records.

Any ideas? I would be most grateful.
 
I have been given a solution already:- Alias the table name. Thanks guys

FYI

Select m.Match_date, t1.Teamname, t2.Teamname from team t1, team t2, match m where m.HomeTeamID = t1.TeamID and m.AwayTeamID = t2.teamID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top