Forum Moderators: coopster

Message Too Old, No Replies

SQL query

         

ricksteruk2005

6:33 pm on Mar 2, 2008 (gmt 0)

10+ Year Member



Im trying to set up a MYsql database for a up coming competition i am running.

If i explain what i am planning to do here i think it will make it easier,
Each competitor takes part, then they enter the results through a web page, the webpage then parses the information to the database, i then need it to show each competitor and their top 12 scores only (they may enter more than 12 but only the top 12 will be used for points) I then need a webpage showing the results.

So far i have set a database up with 2 tables, one for names, this consists of a ID and a name.
I then have another table for the scores, this has ID, a name field propigated from the other table, and their score.

The bit i am stuggling with is how to pull the names from the score table so they only show once and then the scores to be limited to 12 scores only, what would be ideal is that it auto formats as well, so it will show competitor with the highest total score (calculated from their top 12 results) at the top and then 2nd place etc etc.

I hope i have made what i need clear?

TheSpeshulK

1:30 am on Mar 3, 2008 (gmt 0)

10+ Year Member



If you want to limit the amount of rows mysql will grab you should just be able to use the LIMIT keyword and from what I'm understanding you would want to use the DISTINCT keyword so they only show up once. DISTINCT will stop duplicate rows from coming up. If you have questions about certain functions I would recommend checking out php.net.