User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 426,173 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,877 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 3310 | Replies: 0
Reply
Join Date: May 2007
Posts: 1
Reputation: Grumps is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Grumps Grumps is offline Offline
Newbie Poster

Help MySQL Nested Select Issue

  #1  
May 3rd, 2007
This is my current database structure
[php]
create table tournament (
tid int(5) not null auto_increment,
period varchar(20) not null,
Primary key (tid));

create table game (
gid int(6) not null auto_increment,
tid int(5) not null references tournament(tid),
Primary key(gid));

create table results (
gid int(6) not null references game(gid),
pid int(5) not null references player(pid),
point int(2) not null,
Primary key(gid,pid));

create table player (
pid int(5) not null auto_increment,
nick varchar(30) not null,
Primary key(pid)); [/php]


My objective is to create a ranking table that is sorted by user's total point which is based on the top 5 points of the user in the most recent tournament period. Value to retrieve is as below

Ranking | Nick | Total Game Played (in that tournament) | Total points(based on the best 5 points of that user) | List the top 5 points

This will list all the users that have participated in this tournament period. I know is a tricky one, only reason why im here. You can use any php loops or nested statement to do this.

I am already having an alternative solution which is creating a ranking table which fills in the value but im looking for a better way to do it.


[php]create table ranking (
rid int(6) not null auto_increment,
tid int(5) not null references tournament(tid),
pid int(5) not null references player(pid),
totalplay int(2) not null,
point1 int(2) not null,
point2 int(2) not null,
point3 int(2) not null,
point4 int(2) not null,
point5 int(2) not null,
Primary key (rid));[/php]
Last edited by Grumps : May 3rd, 2007 at 11:55 pm.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 6:13 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC