title: Transilerate accents in MySql like LIKE
body: <p>I have a very long list of users. I want to group them by first letter of name. If the first letter is not a letter, it's grouped under <code>#</code>, so I have max 27 groups, for <code>a-z</code> + <code>#</code>.</p>
  
  <p>I want to show only the gorup labels (e.g. <code>F</code>) if it will have results, and for every letter I want to know how many results it will have. So I do a single GROUP query to count all groups:</p>
  
  <pre><code>SELECT
    IF(lastname REGEXP '^[a-z]', UPPER(SUBSTRING(lastname, 1, 1)), '#') first_char,
    COUNT(1) num_users
  GROUP BY first_char
  </code></pre>
  
  <p>That seems to work, BUT using REGEXP means that <code>Ö</code> isn't an <code>O</code>, but a <code>#</code>. That's a problem, because <code>LIKE</code> does find <code>'Ö' = 'O'</code>, so it will be in the <code>O</code> group when I <code>name LIKE 'O%'</code>. I could use REGEXP in the results query too, but I rather file <code>Ö</code> under <code>O</code>.</p>
  
  <p>So the <code>LIKE</code> query works perfectly, but the GROUP query doesn't. How do I do <strong>exactly</strong> what <code>LIKE</code> does during comparisons?, so the group numbers and results always perfectly match.</p>
  
  <p>Or another way to count correctly?</p>
  
  <p><strong>edit 1</strong></p>
  
  <p>Using <code>LIKE a OR LIKE b OR .. OR LIKE z</code> in the <code>IF</code> doesn't even work, because then the group might be <code>Ö</code> instead of <code>O</code>. The numbers will be correct, but the group label won't be. I really need a conversion...</p>
  
  <p><strong>edit 2</strong></p>
  
  <p>Thanks to @mpen. <code>lastname REGEXP '^[[:alpha:]]'</code> is shorter than 26 <code>LIKE</code>s, but the <code>Ö</code> label problem remains. Converting that outside MySQL is easy though.</p>