有两个表商品表goods,订单商品表order_goods。order_goods是卖一个商品就插入一条记录,两个表之间有goods_id关联。我想按照销量排序查出goods商品,应该如何写呢
1 回答
已采纳
CodeManDSH
TA贡献58条经验 获得超18个赞
select * from goods where goods_id in ( select distinct goods_id from order_goods group by goods_id order by count(*) desc );
- 1 回答
- 0 关注
- 1455 浏览
添加回答
举报
0/150
提交
取消