php - MYSQL count based off of two tables -
sorry asking this, haven't found answer i'm trying anywhere!
basically, have database 2 tables. below or 2 examples i'll use:
table 1:
process id date ---------- ----------- 1 2008/08/21 2 2008/08/23 3 2008/08/21
table 2:
process id qty ---------- --- 1 1 2 4 3 6
basically, in php select table 1, , find processes occur today (in example i'll 21st of august). want take process ids, , match them in table 2 , give count of quantities.
the end result i'm trying figure out in example how output "7" using php select processes happened today in 1 table, add corresponding process quantities in table.
select sum(t2.qty) table1 t1 join table2 t2 on t1.pid = t2.pid t1.date = '2008/08/21'
Comments
Post a Comment