title: how to join three tables with one output
body: <p>i have the sql statement below of which i wanted 3 tables to be joined and have 1 output. The thing is, there is no error but it did not show my desired output.</p>
  <pre><code>$sql = &quot;select distinct(sales_table.sales_id), trades_table.t_symbol, round(sum(trades_table.t_volume),2) as totalvol from trades_table inner join accounts_table on trades_table.t_login = accounts_table.a_login inner join sales_table where accounts_table.a_comment = sales_table.sales_id  group by trades_table.t_symbol&quot;;
  </code></pre>
  <p>My Table Files</p>
  <p>sales_table</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>sales_id</th>
  <th>sales_name</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>john</td>
  <td>john doe</td>
  </tr>
  <tr>
  <td>jake</td>
  <td>jake dog</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>trades_table</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>t_deal</th>
  <th>t_login</th>
  <th>t_symbol</th>
  <th>t_volume</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1111</td>
  <td>4000</td>
  <td>fb</td>
  <td>2.00</td>
  </tr>
  <tr>
  <td>1112</td>
  <td>4001</td>
  <td>tesla</td>
  <td>1.00</td>
  </tr>
  <tr>
  <td>1113</td>
  <td>4001</td>
  <td>tesla</td>
  <td>1.00</td>
  </tr>
  <tr>
  <td>1114</td>
  <td>4002</td>
  <td>apple</td>
  <td>3.00</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>accounts_table</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>a_login</th>
  <th>a_name</th>
  <th>a_comment</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>4000</td>
  <td>test1</td>
  <td>john</td>
  </tr>
  <tr>
  <td>4001</td>
  <td>test2</td>
  <td>john</td>
  </tr>
  <tr>
  <td>4002</td>
  <td>test2</td>
  <td>jake</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>The desired output which i have in mind is</p>
  <p>john</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>trades_table.t_symbol</th>
  <th>round(sum(trades_table.t_volume),2)</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>fb</td>
  <td>2.00</td>
  </tr>
  <tr>
  <td>tesla</td>
  <td>2.00</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>jake</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>trades_table.t_symbol</th>
  <th>round(sum(trades_table.t_volume),2)</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>apple</td>
  <td>3.00</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I hope someone can help me on how to properly use inner join for 3 tables.</p>
  <p>Thank you very much</p>