赞
踩
原因:主要是group by 分组后显示的是第一条记录,而max()获取的是相同shop_id中最大的score值造成的。
解决方法:
select
a.counts,
a.shop_id
from
products as a,(select
max(counts) as counts,
shop_id
from
poducts
where
status =1
group by
shop_id
) as b
where a.shop_id=b.shop_id and a.counts = b.counts;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。