title: MYsql Update sequence number in order column for multiple rows
body: <p>I need to update the display_order column with sequence for numbers for array of ids
  Consider the following array of  Ids (13, 6, 5, 19, 1, 3, 2), for this ids i need to update the order column</p>
  <p>DB</p>
  <pre><code>+----+-------+---------------+
  | id | name  | display_order |
  +----+-------+---------------+
  | 1  | cat1  | 3             |
  +----+-------+---------------+
  | 2  | cat2  | 4             |
  +----+-------+---------------+
  | 5  | cat5  | 6             |
  +----+-------+---------------+
  | 6  | cat6  | 1             |
  +----+-------+---------------+
  | 13 | cat13 | 2             |
  +----+-------+---------------+
  </code></pre>
  <p>Currently im using the following query</p>
  <pre><code>UPDATE categories
     SET display_order = CASE id 
                        WHEN 13 THEN 1 
                        WHEN 6 THEN 2 
                        WHEN 5 THEN 3 
                        WHEN 19 THEN 4 
                        WHEN 1 THEN 5 
                        WHEN 3 THEN 6 
                        WHEN 2 THEN 7 
                        
                        END
   WHERE id IN (13, 6, 5, 19, 1, 3, 2);
  </code></pre>
  <p>Currently im looping the ids in PHP to generate the &quot;case when&quot; statement, the array may come with more Ids. Is there any alternative way to do it in Mysql so i can avoid looping.</p>