title: BIGINT UNSIGNED VALUE IS out of range My SQL
body: <p>I'm getting the following error</p>
  
  <blockquote>
    <p>#1690 - BIGINT UNSIGNED value is out of range in '(<code>legends</code>.<code>spawns</code>.<code>quantity</code> - <code>tmp_field</code>)'</p>
  </blockquote>
  
  <p>Here is my query</p>
  
  <pre><code>SELECT drops.common, drops.uncommon, drops.rare, drops.legendary, spawns . *
       , ( quantity - COUNT( game_moblist.spawn_id ) ) AS quantity_to_spawn
       , mobs . * 
  FROM spawns
       LEFT JOIN mobs
            USING ( mob_id ) 
       LEFT JOIN game_moblist
            USING ( spawn_id ) 
       LEFT JOIN drops ON ( 
                 SELECT MAX( level ) 
                   FROM drops
                  WHERE drops.type = mobs.drop_list
                    AND drops.level &lt;= spawns.level ) 
  GROUP BY spawn_id
  HAVING quantity_to_spawn &gt;=0
         AND next_spawn &lt;=0
  </code></pre>
  
  <p>I've been staring at it a while the query is long I'm sorry.</p>
  
  <p>spawns table - count <code>game_moblist.spawn_id</code> is <code>0</code> for all possible rows but 1 (I deleted a row to test the query)</p>
  
  <p>The data otherwise is quite long and irrelevant to my question I think</p>
  
  <p>Any idea how to get around this error?</p>