I was looking for a forum to find a solution to my problem. My problem is that I can’t find out how to maintain the rating position of each tournament that is held. I created two tables and a query that looks like this: competitors (primary key cid int auto_increment, name varchar (25), lastname varchar (25)); comps (compid int auto_increment primary key, tournament int, cid int, points int);
select @rowno:= @rowno+1 as position, rank.* from ( select name,lastname,SUM(points) as pts,group_concat(points) as round FROM (select cid,tournament,points from comps group by cid,tournament order by points)total join competitors c on c.cid = total.cid cross join (select @rowno := 0) r group by total.cid order by pts desc) rank order by pts desc
Here is the SQLFiddle demo
The thing I want to achieve is that when a user clicks on a competitor’s profile, the positions are displayed for each tournament as follows:
Name: Competitor One Tournament 1: 1st 100 pts Tournament 2: 2nd 80 pts Tournament 3: 10th 30 pts
I have grouped the points, but I do not know how to do this with the positions. Is this possible from this query or do I need to create a new table, such as positions (primary key pid int auto_increment, tournament int, cid int, position int), where I insert each position for each participant.
Hope someone understands my problem and can give me some advice or solutions to this problem.
php mysql mysqli ranking
Headpetrol
source share