title: Reset SQL variable inside SELECT statement
body: <p>I am trying to number some rows on a bridge table with a single UPDATE/SELECT statement using a counter variable <code>@row</code>. For example:</p>
  
  <pre><code>UPDATE teamrank JOIN (SELECT @row := @row + 1 AS position, name FROM members) 
         USING(teamID, memberID) SET rank = position
  </code></pre>
  
  <p>Is something like this possible or do I need to create a cursor? If it helps, I am using MySQL 5.</p>