title: Column value of one table should be column headings when query is executed
body: <p>I have two tables: <strong>pet type</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Id</th>
  <th>TypeB</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>dog</td>
  </tr>
  <tr>
  <td>2</td>
  <td>cat</td>
  </tr>
  <tr>
  <td>3</td>
  <td>snake</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Then another <strong>owners</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Ownerid</th>
  <th>Pettype</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>001</td>
  <td>1</td>
  </tr>
  <tr>
  <td>002</td>
  <td>2</td>
  </tr>
  <tr>
  <td>003</td>
  <td>3</td>
  </tr>
  <tr>
  <td>004</td>
  <td>0</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I am trying to get the values those owners who have pets as in this format</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Ownerid</th>
  <th>Cat</th>
  <th>Dog</th>
  <th>snake</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>001</td>
  <td>1</td>
  <td>0</td>
  <td>0</td>
  </tr>
  <tr>
  <td>002</td>
  <td>0</td>
  <td>1</td>
  <td></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>It should display like this format I tried using joins but couldn’t can any one help me out</p>
  <p>I tried using join of three tables</p>