title: mySQL multiple inner joins
body: <p>I have two tables I'm pulling information from.  </p>
  
  <p>Lets say table1 has following columns 
  (id, title, category, sub_category, sub_sub_category)</p>
  
  <p>Lets say table2 has following columns
  (category_id, category_name)</p>
  
  <p>I have a select statement that so far looks as follows:</p>
  
  <pre><code>SELECT
    table1.id,
    table1.title,
    table2.category_name as Cat1,
    table2.category_name as Cat2,
    table2.category_name as Cat3
  FROM
    table1,
    table2
  INNER JOIN table2 as c1 ON c1.category_id = table1.category
  INNER JOIN table2 as c2 ON c2.category_id = table1.sub_category
  INNER JOIN table2 as c3 ON c3.category_id = table1.sub_sub_category
  WHERE
    table1.id = ?
  </code></pre>
  
  <p>This gives me an error about table1.category being an unknown column</p>
  
  <p>I have also tried</p>
  
  <pre><code>SELECT
    table1.id,
    table1.title,
    table2.category_name as Cat1,
    table2.category_name as Cat2,
    table2.category_name as Cat3
  FROM
    table1,
    table2
  WHERE table1.id = ?
  AND   table1.category = table2.category_id
  AND   table1.sub_category = table2.category_id
  AND   table1.sub_sub_category = table2.category_id
  </code></pre>
  
  <p>The last example at least gives me column output I'm looking for which would be</p>
  
  <p>(table1.id, table1.title, table1.category name, table1.sub_category name...)</p>
  
  <p>So showing the category name from table 2 instead of the ID's.  I am an amateur coder and haven't had to use inner joins before but maybe that is what I need to do.  I just can't figure out how to get it to output the data I need.</p>
  
  <p>Thank you in advance for your time and consideration.</p>