title: How to add "rank" column to mysql table depending on the score with different categories?
body: <p>My table:</p>
  
  <pre><code>user | score | category
  -----------------------
   1   |  20   |    1
   2   |  30   |    1
   4   |  30   |    1
   1   |  20   |    2
   2   |  30   |    2
   4   |  30   |    3
  </code></pre>
  
  <p>Expected result:</p>
  
  <pre><code>user | score | category | rank
  ------------------------------
   1   |  20   |     1    |  3
   2   |  30   |     1    |  1
   4   |  30   |     1    |  1
   1   |  20   |     2    |  2
   2   |  30   |     2    |  1
   4   |  30   |     3    |  1
  </code></pre>
  
  <p>I need to make a permanent change to the table (not only select this value) so that I could select users like:</p>
  
  <pre><code>SELECT `user`, `rank`, `score` FROM `user` WHERE `category` = 2
  </code></pre>
  
  <p>My real table is 200k+ rows and has much more columns. It has to be fast.</p>