title: Gettin NULL value when numbering SQL tuples from SELECT
body: <p>I need to get a progressive number next on each row out of my SELECT query.</p>
  
  <p>i.e. Query result without numbering:</p>
  
  <pre><code>user_id
  paola
  Carla
  Marta
  </code></pre>
  
  <p>what i want is</p>
  
  <pre><code>number user_id
  1      paola
  2      Carla
  3      Marta
  </code></pre>
  
  <p>I am aware that the problem is very similar to the one in</p>
  
  <p><a href="https://stackoverflow.com/q/2520357/3008431">MySQL - Get row number on select</a></p>
  
  <p>And on the first query the code suggested in the answers seems to work for me too BUT when I recall the query, or when i try to export the results, i get a NULL value in the column where the row number is supposed to be.</p>
  
  <p>Do you know why?
  Did I do something wrong in the variable instance?</p>
  
  <p>The code I use is the following:</p>
  
  <pre><code>set @x=0;
  
  SELECT @x:=@x + 1 AS row_index, user_id FROM TABLE ORDER BY user_id
  </code></pre>