【发布时间】:2012-10-08 10:43:21
【问题描述】:
如果我有一个嵌套的类别集,如下所示:
Widgets
Blue
Red
Green
我使用关系表将产品引用到这些类别,例如
产品:
id name
1 Glowing Widget
2 Flying Widget
3 Exploding Widet
关系表:
id productId categoryId
1 1 2
2 2 3
3 3 4
有没有什么方法可以创建一个查询来判断一个类别及其子类别引用了多少产品?
【问题讨论】:
-
您的意思是像在单个查询中使用
COUNT()和INNER JOIN?
标签: mysql nested-sets