
查找属于3个以上私有类别的产品列表的SQL是什么。
我试过这个:
SELECT
    products.*
FROM
    products
    INNER JOIN
    product_categories
    ON 
        products.product_id = product_categories.product_id
    INNER JOIN
    categories
    ON 
        product_categories.category_id = categories.category_id
WHERE
    categories.is_private = 1
GROUP BY
    categories.category_id
HAVING
    COUNT(categories.category_id) > 3谢谢!
发布于 2020-08-31 21:40:24
看看这个!
select * from products where product_id in 
(select pc.product_id from product_categories inner join categories c on 
pc.category_id=c.category_id where c.is_private=1 
group by c.category_id having count(c.category_id)>3)https://stackoverflow.com/questions/63671240
复制相似问题