title: How to get the next number in a sequence
body: <p>I have a table like this:</p>
  
  <pre><code>+----+-----------+------+-------+--+
  | id | Part      | Seq  | Model |  |
  +----+-----------+------+-------+--+
  | 1  | Head      | 0    | 3     |  |
  | 2  | Neck      | 1    | 3     |  |
  | 3  | Shoulders | 2    | 29    |  |
  | 4  | Shoulders | 2    | 3     |  |
  | 5  | Stomach   | 5    | 3     |  |
  +----+-----------+------+-------+--+
  </code></pre>
  
  <p>How can I insert another record with the next seq after <code>Stomach</code> for Model 3. So here is what the new table suppose to look like:</p>
  
  <pre><code>+----+-----------+------+-------+--+
  | id | Part      | Seq  | Model |  |
  +----+-----------+------+-------+--+
  | 1  | Head      | 0    | 3     |  |
  | 2  | Neck      | 1    | 3     |  |
  | 3  | Shoulders | 2    | 29    |  |
  | 4  | Shoulders | 2    | 3     |  |
  | 5  | Stomach   | 5    | 3     |  |
  | 6  | Groin     | 6    | 3     |  |
  +----+-----------+------+-------+--+
  </code></pre>
  
  <p>Is there a way to craft an insert query that will give the next number after the highest seq for Model 3 only. Also, looking for something that is concurrency safe.</p>