title: How does MySQL CASE work?
body: <p>I know that SQL's <code>CASE</code> syntax is as follows:</p>
  
  <pre><code>CASE
      WHEN search_condition THEN statement_list
      [WHEN search_condition THEN statement_list] ...
      [ELSE statement_list]
  END CASE
  </code></pre>
  
  <p>However, I don't understand how this works, possibly because I'm thinking about it as about an <code>if</code> statement.</p>
  
  <p>If I have a field in table <code>user_role</code>, for example, which contains names like "Manager", "Part Time" etc., how do I generate a field <code>role_order</code> with a different number depending on the role. In the case of this example, "if user_role = 'Manager' then role_order = 5".</p>
  
  <p>Please note I am looking for a <em>teach a man how to fish</em> answer rather than <em>give a man a fish</em> answer.</p>