title: How to CONCAT numbers with filled zero values in mysql?
body: <p>I need to generate a ten digits product code (for bar code generation) for a fashion store, which is a combination of:</p>
  
  <p>collectionYear (this or next year), two digits, e.g. 14 or 15</p>
  
  <p>collectionSeason (spring to winter) one digit, e.g. 1 for spring</p>
  
  <p>productId (from 1 to 99.999 with zeros filled), e.g. 12 -> 00012</p>
  
  <p>productVariant (from 1 to 99 with zero filled), e.g. 2 -> 02</p>
  
  <p>The result should be something like this: 1510001202</p>
  
  <p>Using php I would do this like this:</p>
  
  <pre><code>$year = str_pad($year, 2 ,'0', STR_PAD_LEFT); // for future safety, e.g. 2102 :-)
  $prodId = str_pad($prodId, 5 ,'0', STR_PAD_LEFT);
  $prodVar = str_pad($prodVar, 2 ,'0', STR_PAD_LEFT);
  
  $finalCode = $year.$season.$prodId.$prodVar;
  </code></pre>
  
  <p>Is there a mysql syntax equiv for this like</p>
  
  <pre><code>SELECT CONCAT(collectionYear,collectionSeason,productIdproductVariant) AS prodCode
  </code></pre>
  
  <p>with the zero fill functions included ??</p>
  
  <p>Thanks for your engagement.</p>