title: PHP MYSQL query result "RANKING"
body: <p>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:</p>
  
  <pre><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 &gt;= %s) AND (users.idade &lt;= %s)
  GROUP BY points.iduser ORDER BY pontos DESC) AS totals WHERE iduser = %s
  </code></pre>
  
  <p>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".</p>
  
  <p>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?</p>