按总销售额分组的收益产品?

问题描述:

我有以下MySQL表:按总销售额分组的收益产品?

TABLE: Products 
---------------------- 
id | productname 
1030 | xBox 360 
1031 | PlayStation 3 
1032 | iPod Touche 

TABLE: Sales 
---------------------- 
productid | saledate 
1031  | 2010-06-14 06:30:12 
1031  | 2010-06-14 08:54:38 
1030  | 2010-06-14 08:58:10 
1032  | 2010-06-14 10:12:47 

我想用PHP我今天售出的产品来获取和销售数量和顺序由发售日期(如果可能)的输出,例如狮其中:

Today's statistics: 
-Playstation 3 (2 sales) 
-Xbox 360 (1 sale) 
-iPod Touche (1 sale) 

感谢

大卫,

沿东西(未经测试)的线路:

select 
p.productname, 
count(s.productid) 
from sales s inner join products p 
on p.id=s.productid 
where s.saledate=curdate() 
group by p.productname 

正如我所说的,未经测试,但感觉上像它会做什么你以后。

吉姆