title: Mysql selecting with sum() and group by from multiple tables
body: <p>TABLE 1  </p>
  
  <pre><code>---------------------------------------
  | id | item | MU | quantity | file_id |
  ---------------------------------------
  | 1  |item1 | oz | 3.5      | 003     |
  | 2  |item2 | kg | 1.1      | 001     |
  | 3  |item1 | oz | 0.2      | 001     |
  | 3  |item1 | kg | 3        | 001     |
  </code></pre>
  
  <p>TABLE 2</p>
  
  <pre><code> ----------------------------
   | id | date      | file_id |
   ----------------------------
   | 1  |timestamp1 | 001 |
   | 2  |timestamp2 | 002     |
   | 3  |timestamp3 | 003     |
  </code></pre>
  
  <p>What i'm trying to do is to select the sum of quantity for each group of items that have the same MU. I manage to do that with this query.</p>
  
  <pre><code>$query = "SELECT item,SUM(quantity) from table1 GROUP BY item,mu";
  
  with a great result, exactly what i wanted
  ----------------------------------
  | id | item | MU | SUM(quantity) |
  ----------------------------------
  | 1  |item1 | oz | 3.7           |
  | 2  |item2 | kg | 1.1           |
  | 3  |item1 | kg | 3             |
  </code></pre>
  
  <p>But now, how do i get <strong>only</strong> the rows that their file_id date is BETWEEN two timestamps ?</p>