title: SQL Multiple INNER JOINS In One Select-Statement
body: <p>I am using this code for inventory management system, in which i want to retrieve stock in hand from four tables. i have tried with two table and got accurate result as i need it.please help me out.</p>
  
  <p>Table Schema</p>
  
  <p><strong>Productmastertb</strong></p>
  
  <pre><code>prod_id,
  Product_name
  </code></pre>
  
  <p><strong>salesdetailstb</strong></p>
  
  <pre><code>sales_id,
  Prod_id,
  Prod_qty
  </code></pre>
  
  <p><strong>estimatedetailstb</strong></p>
  
  <pre><code>est_id,
  Prod_id,
  Prod_qty
  </code></pre>
  
  <p><strong>Purchasedetailstb</strong></p>
  
  <pre><code>est_id,
  Prod_id,
  Prod_qty
  </code></pre>
  
  <p>Query example (working):</p>
  
  <pre><code>SELECT
      productmastertb.prod_id, 
      productmastertb.prod_name, 
      sum(estimatedetailstd.prod_qty) as Est_qty 
  FROM 
      productmaster 
  INNER JOIN 
      estimatedetailstb ON productmastertb.prodid = estimatedetails.prodid 
  GROUP BY 
      productmastertb.prod_id, productmastertb.prod_name
  </code></pre>
  
  <p>Similarly I have to retrieve sum of salesdetailstb.qty and purchasedetailstb.qty</p>
  
  <p>Thanks in advance</p>