Search Results

Search found 1 results on 1 pages for 'fkessler'.

Page 1/1 | 1 

  • PHP MYSQL query result "RANKING"

    - by fkessler
    Hi, I need to get a list of users Ranking by points and from my command line (MySQL) is was able to generate the necessary code: SET @rank=0; SELECT rank, iduser, pontos FROM ( SELECT @rank:=@rank+1 AS rank, SUM(points.points) AS pontos, points.iduser, users.name, users.idade FROM points INNER JOIN users ON (points.iduser = users.id) WHERE (users.idade >= %s) AND (users.idade <= %s) GROUP BY points.iduser ORDER BY pontos DESC) AS totals WHERE iduser = %s The problem is that I need this to run on AMFPHP and I´ve tested it in a test PHP file and seems that I can´t use the SET and SELECT in the same "mysql_query". I´ve looked and some used to mysql_query to do this (I´ve tested it and it works), but can I trust this to be effective and error free? Does it work like in MySQL transactions or setting the @rank in a seperated query may cause unexpected results?

    Read the article

1