title: sql simple 3 table join using same table?
body: <p>I have two tables:</p>
  
  <p><strong>Table 1</strong><br>
  id, name1</p>
  
  <p><strong>Table 2</strong><br>
  id, name2a, name2b</p>
  
  <p>Table 2's column names name2a, and name2b are references to table 1's id. I need to create a query that pulls both the names out of table 1 based on the id's used in Table 2.</p>
  
  <p>Therefore, if Table one contained:</p>
  
  <pre><code>1 Peter
  2 Paul
  </code></pre>
  
  <p>And Table 2 contained:</p>
  
  <pre><code>1 1 2
  2 2 2
  </code></pre>
  
  <p>Then a select statement should give me:</p>
  
  <pre><code>Peter Paul
  Paul Paul
  </code></pre>
  
  <p>I've gone around the bend trying to build this SQL and the best I came up with was:</p>
  
  <pre><code>SELECT table1.name AS 'name', table1.name AS 'Other name'
  FROM table1, table2
  WHERE table1.id = table2.name2a
  </code></pre>
  
  <p>Which only gives me the name2a column correctly.</p>
  
  <p>Any help appreciated! I guess I need to do a join, but I'm really struggling...</p>