mysql - 显示多个类别的产品

发布于 2024-12-01 21:13:05 字数 191 浏览 4 评论 0原文

我找不到这个问题的答案。

我希望能够返回对多个类别的 Virtuemart (Joomla! + Virtuemart) 产品的查询。目前它们可能属于 8 个类别(可能会增加)。

因此,用户可以选择任意数量的类别,并且我想要返回一个仅包含所有选定类别中的产品的列表。

我怎样才能在 MySQL 中执行处理这个问题的查询?

I cannot find an answer to this issue.

I want to be able to return a query of Virtuemart (Joomla! + Virtuemart) products that are in more than one category. There are currently 8 categories they could be in (which may grow.)

So a user could potentially select any number of categories and I want back a list of only products that are in ALL selected categories.

How could I do a query that handles this in MySQL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由范儿 2024-12-08 21:13:05

我不知道你的表结构,但这个例子可能会给你一个想法。

select product
from categories
where category in ('cat1','cat2','cat3')
group by product
having count(distinct(category)) = 3

I don't know your tables structure but this example might give you an idea.

select product
from categories
where category in ('cat1','cat2','cat3')
group by product
having count(distinct(category)) = 3
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文