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

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

Post your reply

Text Format: Table: Smilies:
Forum does not support HTML
Insert Photo
Cancel
sort by:
Show
per page
Replies: 4
By:
pxb
When: 02 Nov 10 07:41
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.
By:
dude67
When: 02 Nov 10 07:49
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
By:
chelseagirl
When: 02 Nov 10 08:13
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
By:
Apple Pie
When: 02 Nov 10 16:37
thanks for the help, its sorted now.
sort by:
Show
per page

Post your reply

Text Format: Table: Smilies:
Forum does not support HTML
Insert Photo
Cancel
‹ back to topics
www.betfair.com