Selasa, 26 November 2013

[MS_AccessPros] Help with query

 

Hi

 

I am having trouble working out how best to create this query and I wondered if someone could give me some pointers.

 

I have the following tables (relevant data only)

 

Teams

id

team name

 

Matches

id

date

hometeamid   (looks up team name from teams.id)

awayteam id   (looks up team name from teams.id)

derby

 

Derbies

id

team1    (looks up team name from teams.id)

team2    (looks up team name from teams.id)

rating1    (this is a rating for this derby fixture when team1 is the home team)

rating2    (this is a rating for this derby fixture when team2 is the home team)

 

when a match record has been created (by bulk external import) I want to be able to update the record if applicable with the correct derby rating.

 

A match has a home team and an away team and I want to find (if it exists) the derby record for this match and then pick up the appropriate rating figure depending on which team is at home.

 

So from the match record I need to establish if there is a derby record for the 2 teams involved and then apply a rating depending on whether hometeam id = team1 or team2

 

I suspect I will need at least one level of 'prequery' but as I say I can't get my head around it at the moment

 

Help please!!

 

Phil

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (7)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar