title: MySQL select with INNER JOIN and CASE WHEN in INNER JOIN
body: <p>I have a data base with Characters. Since Names of the Characters are not only use once the Names are seperate from the Characters. Since there are <code>Male</code> and <code>Female</code> characters I keep these in diffent Tables:</p>
  
  <blockquote>
    <p>tbl_player, tbl_maleName, tbl_femaleName</p>
  </blockquote>
  
  <p>In my MySQL <code>Select</code> query i'd like to Select the correct tables with an <code>INNER JOIN</code> depending on what gender they have. So something like this: 
  (The SQL query is wrong and doesn't work :( )</p>
  
  <pre><code> SELECT tbl_player.id, 
  (CASE tbl_player.gender
      WHEN 'm' THEN tbl_maleName.name
      WHEN 'f' THEN tbl_femaleName.name
  END) as gamerName
  , tbl_player.gender
  FROM tbl_player
  INNER JOIN
  (CASE tbl_player.gender
      WHEN 'm' THEN tbl_maleName ON tbl_player.gamerName = tbl_maleName.id
      WHEN 'f' THEN tbl_femaleName ON tbl_player.gamerName = tbl_femaleName.id
   END)
  </code></pre>
  
  <p>Thanks in advance!</p>