title: Select from 3 tables where 3 conditions SQL and Codeigniter
body: <p>I'm facing some troubles with a query that i cannot complete, the main problem is that i'm joining 2 tables and adding 2 conditions:</p>
  
  <pre><code>SQL Table
  Products table:
  id,name,section
  1,Product 1,Computer
  2,Product 2,Computer
  3,Product 3,Computer
  4,Product 4,Computer
  
  Table1:
  id,pr_id,value,qty
  1,2,1
  
  Table2:
  id,pr_id,value,qty
  1,1,2,1
  1,2,2,2
  1,3,2,3
  1,3,3,1
  1,3,4,1
  
  $itemsIds = array('1', '2', '3');
  $value = 2;
  $q = $this-&gt;db-&gt;select('Ai.id as AiId, Ai.pr_id as AiPrId, Ai.value as AiValueId, Ai.qty as AiQty, AiR.id as AiRId, AiR.pr_id as AiRPrId, AiR.value as AiRValueId, AiR.qty as AiRQty, P.name as pName')
      -&gt;from('products P')
      -&gt;where_in('P.id', $itemsIds)
      -&gt;join('table1 Ai', 'P.id=Ai.pr_id', 'left')
      -&gt;join('table2 AiR', 'P.id=AiR.pr_id', 'left')
      -&gt;where(array('AiValueId' =&gt; $value, 'AiRValueId' =&gt; $value))
      -&gt;group_by('P.id')
      -&gt;get();
  </code></pre>
  
  <p>The main problem is that with this Conditions im getting only the table 1 values and not the table 2 values too.
  My question is how can i get the Table1 and Table2 with the conditions?</p>