Forums

We want to share an important update with our Betfair Community users.

Over the coming months, the Betfair Community platform will be winding down. The final active day for the platform will be December 21st. From December 22nd, users will no longer be able to access the platform.

Your discussions, insights, engagement, and, most importantly, feedback have helped shape the platform and guided innovation. Your feedback continues to be important to us, and we will continue to listen via our dedicated feedback channels, as well as through product testing and innovations.

To share your feedback and experience, visit: https://support.betfair.com/app/home

General Betting

Welcome to Live View – Take the tour to learn more
Start Tour
There is currently 1 person viewing this thread.
Apple Pie
02 Nov 10 05:49
Joined:
Date Joined: 15 Sep 03
| Topic/replies: 26 | Blogger: Apple Pie's blog
I'm trying to join a match with the names of the two teams.  I'm not sure how to do this type of query.

ie
Select * from matches,teams where matches.awayTeam= teams.teamId as awayTeamName and matches.homeTeam= teams.teamId as homeTeamName

hmm, but thats not right cos I need teams.team as homeTeamName/awayTeamName where matches.awayTeam=teams.teamId

Ive googled a lot, I can't really find anything.  Some help would be greatly appreciated
Show More
Loading...
Report pxb • November 2, 2010 6:41 AM GMT
I'm kinda rusty at this stuff, but one way is to use a view.

You'll have to look up the correct syntax.

Create view myview as
Select * from matches,teams
where matches.awayTeam= teams.teamId as awayTeamName

Select * from myview, teams
where myview.homeTeam= teams.teamId as homeTeamName


Otherwise, I think you need a correlated subquery.
Report dude67 • November 2, 2010 6:49 AM GMT
You need to introduce two table aliases for the team tables:

SELECT *
FROM matches, teams AS t1, teams AS t2
WHERE matches.awayTeam = t1.teamId AND matches.homeTeam = t2.teamId
Report chelseagirl • November 2, 2010 7:13 AM GMT
Try:

SELECT ht.TeamName AS HomeTeam,
       at.TeamName As AwayTeam,
       m.*
FROM Matches m
JOIN Teams ht ON ht.TeamId = m.homeTeam
JOIN Teams at ON at.TeamId = m.awayTeam
Report Apple Pie • November 2, 2010 3:37 PM GMT
thanks for the help, its sorted now.
Post Your Reply
<CTRL+Enter> to submit
Please login to post a reply.

Wonder

Instance ID: 13539
www.betfair.com