你的表设计有问题 商品表goods 中不该有字段cat_id ,goods_id都对应多个 cat_id,会使goods表中的商品信息数据重复出现(比如 cat_id :1 商品A cat_id :2 商品A);商品分类表goods_cat已经记录了各个商品与商品分类的信息
去掉商品表goods 的字段cat_id
sql语句
SELECT g.goods_id from
arctype a,goods_cat c,goods g where a.ecshop_id=c.cat_id and c.goods_id=g.goods_id ORDER BY g.bought_num desc
select c.*
from arctype a
inner join goods_cat b on a.对应字段 = b.对应字段
inner join goods c on b.cat_id = c.cat_id
order by c.bought_num