title: How to combine two update queries(MySQL)
body: <p>I have two SQL Queries:
  1. Get the the next row a row of where its status is "Active", Set it also to 'Active'
  2. Remove the status of the previous row from the first sql query. Meaning, I want to remove the status of current row, move it to the next.</p>
  
  <ol>
  <li>Code</li>
  </ol>
  
  <pre><code>UPDATE x AS a
      INNER JOIN (
          SELECT id, count(*) FROM x WHERE id=(select min(id) FROM ref_school_year where id &gt; (SELECT ID FROM x WHERE status='START'))
      ) AS b on a.id = b.id
  SET a.status = 'START'
  WHERE a.id &gt; 0
  
  </code></pre>
  
  <ol start="2">
  <li>Second sql query</li>
  </ol>
  
  <pre><code>UPDATE ref_school_year as a
  INNER JOIN(
          SELECT * FROM ref_school_year
          WHERE status='START'
          ORDER BY id LIMIT 1
  ) as b on b.id = a.id
  SET a.status=null
  WHERE a.id &gt; 0
  
  </code></pre>
  
  <p>Ex.</p>
  
  <pre><code>Before Query:
  -----------------------------
  | Rows     |     Status     |
  -----------------------------
  | 1        |    Active      |
  | 2        |    null        |
  </code></pre>
  
  <pre><code>After Queries:
  -----------------------------
  | Rows     |     Status     |
  -----------------------------
  | 1        |    null        |
  | 2        |    Active      |
  </code></pre>