小编Sri*_*ian的帖子

MySQL和分面导航(按属性过滤)

我觉得这个问题可能已经被问过了一千次,所以如果有人回答,我会道歉.如果是这样,有人能指出我正确的帖子/链接?

我要做的是为我的网站构建一个分面导航.它使用MySQL,这里是我正在使用的表的草图:

products:
- id
- title
- description
attributes:
- product_id
- name
- value
categories:
- id
- name
products_to_categories:
- product_id
- category_id

我想要做的是当你在一个类别时显示可用属性列表,允许你为每个属性选择一个或多个值.举个例子,请查看Office Depot的这个页面:http://www.officedepot.com/a/browse/binders/N=5+2177/

到目前为止,我已经使用了很多连接来过滤多个属性:

SELECT products.*, a_options.*
FROM products_to_categories AS pc, products,
attributes AS a_options,    /* list of attribute/value pairs I can continue to refine on */
attributes AS a_select1     /* first selected attribute */
attributes AS a_select2     /* second selected attribute */
...
WHERE pc.category_id = 1
AND products.id = pc.product_id …

mysql multiple-tables faceted-search

3
推荐指数
2
解决办法
5538
查看次数

标签 统计

faceted-search ×1

multiple-tables ×1

mysql ×1