help with query

B

Bisha

I have three tables : Quotas, Results, and Predictions. In the Quotas I have
for each match the koeficent for Win, Loose (eg. Team1-Team2, Win=1.5,Loose
=1.7).
The Results its the result of the game (Team1-Team2:Win=1 Loose=2), and the
Prediction is the what result somebody choosed for that game (Team1-Team2:
Result = 1).
Now I need to have a query that if the Prediction for a game = Result of the
game (we have a winner) take the koeficent from the Quotas that correspond to
Win or Loose based on the result (need the koeficent).
Thanks in adavance
 
D

David S via AccessMonster.com

Should be simple to do, but it depends a lot on your table layout. What are
the fields in the Quotas, Results and Predictions tables, and can you post
some sample contents?

Assuming that:
* Quotas contains MatchID (eg. Team1-Team2), ResultID (eg. Win, Lose) and
koeficient (1.5, 1.7)
* Results contains MatchID, ResultID, Result (eg. 1, 2)
* Predictions contains UserID (eg. David, Bisha), MatchID and Prediction (eg.
1, 2)

then a query to deliver your answer would look like:
SELECT Predictions.UserID, Quotas.koeficient
FROM Quotas INNER JOIN (Predictions INNER JOIN Results ON Predictions.MatchID
= Results.MatchID) ON Quotas.ResultID = Results.ResultID;

However, you'd probably want to sum that up for each user, depending on what
you want to do with the coefficients once you retrieve them...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top