【发布时间】:2013-04-17 12:44:27
【问题描述】:
我有两个表(MySQL):
-
table_products: // cid (text) - 逗号分隔的类别列表 // id (int11)
id cid 1 1,2,3 2 5,21,8 3 2,4,15 -
table_categories
id name parent 1 Cat1 0 2 Cat2 0 3 Cat3 0 4 Cat4 0
这是我的要求:
SELECT `id`, `name`, `parent`
FROM `table_categories`
ORDER BY `parent` ASC, `id` ASC;
如何执行上述请求并获取每个类别中的产品数量(来自 table_products)。 可能正在使用 (FIND_IN_SET)。
【问题讨论】: