title: Mysql query two table join with reference table
body: <p>hi i have two table like this :</p>
  
  <p>TABLE 1:</p>
  
  <pre><code>name | distro1 | distro2 | distro3
  ----------------------------------
  foo  | 001     | 002     | 003
  </code></pre>
  
  <p>TABLE 2:</p>
  
  <pre><code>id  | distro 
  ---------------
  001 | slackware
  002 | redhat
  003 | debian
  </code></pre>
  
  <p>i want get select result like this = </p>
  
  <pre><code>name | dis1      | dis2   | dis3
  ----------------------------------
  foo  | slackware | redhat | debian
  </code></pre>
  
  <p>The query needed to create those source tables.</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `table1` (
    `name` varchar(30) NOT NULL,
    `distro1` varchar(30) NOT NULL,
    `distro2` varchar(30) NOT NULL,
    `distro3` varchar(30) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  INSERT INTO `table1` (`name`, `distro1`, `distro2`, `distro3`) VALUES
  ('foo', '001', '002', '003');
  
  CREATE TABLE IF NOT EXISTS `table2` (
    `id` varchar(30) NOT NULL,
    `distro` varchar(30) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  INSERT INTO `table2` (`id`, `distro`) VALUES
  ('001', 'slackware'),
  ('002', 'readhat'),
  ('003', 'debian');
  </code></pre>