title: Using If or Case (or any other method) to increment a value based on country code
body: <p>I have this table built like this, which assigns a unique articleId starting with zero for each user.</p>
  
  <pre><code>CREATE TABLE `articles` (
    `artcId` INT(10) NOT NULL AUTO_INCREMENT,
    `artcUserId` INT(10) NOT NULL DEFAULT '0',
    `artcStackId` INT(10) NOT NULL DEFAULT '0',
    `artcTitle` VARCHAR(200) NULL DEFAULT NULL,
    PRIMARY KEY (`artcUserId`, `artcId`)
  )
  COLLATE='utf8_general_ci'
  ENGINE=MyISAM;
  </code></pre>
  
  <p>There also is a part which assigns a running serial number (artcStackId) to each article. You'll see in the code.</p>
  
  <p>Thing is, is it somehow possible to assign a artcStackId based on the country of the user? That country code will come from php.</p>
  
  <p>Eg: If it's US then start from 10001+1, if its UK start from 20001+1, if its CA then start from 30001+1 and on &amp; on.</p>
  
  <p>Will it be possible to do this?</p>
  
  <p>My current SQL query goes as follows:</p>
  
  <pre><code>insert into articles (artcUserId, artcStackId, artcCountry, artcTitle)
  select 4,IFNULL((MAX(artcStackId)+1) ,0),'US','Hello World'
  FROM articles;
  </code></pre>
  
  <p>But the way I want it it'll have to go like (this is just an example sql):</p>
  
  <pre><code>insert into articles (artcUserId, artcStackId, artcCountry, artcTitle)
  select 4, IF artcCountry = 'US' then (selct MAX(artcStackId)+1
                                        where artcCountry = 'US'),
         'US','Hello World'
  FROM articles;
  </code></pre>
  
  <p>I hope you get the idea.</p>
  
  <p><img src="https://i.stack.imgur.com/idzdZ.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/FaFwG.png" alt="enter image description here"></p>