TABLE 1
---------------------------------------
| 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 |
TABLE 2
----------------------------
| id | date | file_id |
----------------------------
| 1 |timestamp1 | 001 |
| 2 |timestamp2 | 002 |
| 3 |timestamp3 | 003 |
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.
$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 |
But now, how do i get only the rows that their file_id date is BETWEEN two timestamps ?