title: Storing leading zeros of integers in MySQL database as INTEGER
body: <p>I need MySQL to store numbers in a integer field and maintain leading zeros. I cannot use the zerofill option as my current field is Bigint(16) and numbers can vary in amount of leading zeros. IE: 0001 - 0005, then 008 - 010 may need to be stored. I am not concerned about uniqueness of numbers (these aren't being used as IDs or anything) but I still need them to be stored preferably as INTS. </p>
  
  <p>The issue using CHAR/VARCHAR and then typecasting the values as integers in PHP means that sorting results via queries leads to alphanumeric sorting, IE: SORT BY number ASC would produce</p>
  
  <pre><code>001
  002
  003
  1
  100
  101
  102
  2
  </code></pre>
  
  <p>Clearly not in numerical order, but in alphanumeric order, which isn't wanted.</p>
  
  <p>Hoping for some clever workarounds :)</p>