商品和属性的条件查询sql,解决根据属性查询商品筛选,通过having实现

  • Post author:
  • Post category:其他


SELECT
wst_jxc_goods.goodsId,
wst_jxc_goods.goodsName,
wst_jxc_screening_goods_relation.relation_id,
count(wst_jxc_screening_goods_relation.goods_id) countTmp
FROM
wst_jxc_screening_goods_relation
INNER JOIN wst_jxc_goods ON wst_jxc_goods.goodsId = wst_jxc_screening_goods_relation.goods_id
WHERE
wst_jxc_screening_goods_relation.is_delete = 0 AND
(wst_jxc_screening_goods_relation.screening_id = 6 or wst_jxc_screening_goods_relation.screening_id = 7 or wst_jxc_screening_goods_relation.screening_id = 8)
GROUP BY
wst_jxc_screening_goods_relation.goods_id having count(wst_jxc_screening_goods_relation.screening_id) = 3
LIMIT 10

因为属性也是需要支持多个属性组合筛选,具体有空再做详细解释,这里仅记录一下



版权声明:本文为qq_22598991原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。