title: Join multiple SQL tables
body: <p>Not working</p>
  
  <pre><code>SELECT a.name, atn.name
  FROM t1 a
      JOIN t2 ap ON a.id = ap.area_id
      JOIN t3 atn ON atn.id = ap.parent_id
  </code></pre>
  
  <p>I have a table t1 with area names and their type (like pin, ward and simple area name) and table t2 with their mapping and table t3 with type name and their id's.</p>
  
  <p>I want a result with three columns (area name, pin, ward) i.e the result should be which area comes under pin and ward.</p>
  
  <p><code>t1</code>:</p>
  
  <pre><code>    --------------------------
      | id  |  area name | type |
      ---------------------------
      | 1   |  a         | 5    |
      | 2   |  b         | 8    |
      | 3   |  x         | 7    |
      | 4   |  z         | 8    |
      | 5   |  pq        | 8    |
      ---------------------------
  </code></pre>
  
  <p><code>t2</code>:</p>
  
  <pre><code>    ------------------------------
      | id  |  area_id | parent_id |
      ------------------------------
      | 1   |  2       |   1       |
      | 2   |  2       |   3       |
      | 3   |  4       |   1       |
      | 4   |  5       |   3       |
      -----------------------------
  </code></pre>
  
  <p><code>t3</code>:</p>
  
  <pre><code>    ------------------
      | id  |  name    |
      ------------------
      | 5   |  pin     |
      | 7   |  ward    |
      | 8   |  area    |
      ------------------
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>    --------------------------
      | area  |  pin   | ward  |
      --------------------------
      | b     |  a     |   x   |
      | z     |  a     |       |
      | pq    |        |   x   |
      --------------------------
  </code></pre>
  
  <p>Anybody knows how to get this, please help me. I don't know how to get that value. I tried but couldn't find anything.</p>