Link to home
Start Free TrialLog in
Avatar of mvwmail
mvwmail

asked on

SQL Query

Hopefully a simple one, thouhg I am too knackered to work it out (lazy oik)

I have a MATCH table which has a home team and an away team

MatchID (PK)
HomeTeam
AwayTeam

Both the Home and Away team pull off the team from the same table of teams

TEAMS
TeamID (PK)
TeamName

There is more information but it is not important.

I know how to code a simple SELECT staement using a JOIN to pull of the name of ONE of the teams, but have never done it for TWO.. any help appreicated.

Thanks
Avatar of smaglio81
smaglio81

SELECT      tone.TeamName as HomeTeam, ttwo.TeamName as AwayTeam
FROM      m INNER JOIN
            teams tone ON m.HomeTeam = tone.TeamID INNER JOIN
            teams ttwo ON m.AwayTeam = ttwo.TeamID
WHERE      m.MacthID = <cfqueryparam cfsqltype="cf_sql_integer" value="#id#" />
Avatar of mvwmail

ASKER

My app does not like that at ALL, throws a wobbler.. and I cant work throuhg it enouhg to debug. Dont know if it makes a difference but my database is Access.

Will have another go in a bit.. need coffee
I don't know then. I don't have enough experience with Access and Coldfusion.

Steven
ASKER CERTIFIED SOLUTION
Avatar of INSDivision6
INSDivision6

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mvwmail

ASKER

Fantastic..
works a treat.. thanks =)