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

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

商品和属性的条件查询sql,解决根据属性查询商品筛选,通过having实现_第1张图片

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

你可能感兴趣的:(数据库,后端,sql,数据库,database)