我需要将 osCommerce 产品数据库导出到 Excel。目前有几张表:
- Products (list with all the products)
- Options (labels of the different options, e.g. size, color, etc)
- Options_Products (list will all the options for a given product, organised by product_id, option_id and value (e.g. red, 32, etc.))
我必须在一行上导出每个产品,每个选项(例如颜色)有一列,并在所有值中(逗号分隔)。如果某些选项不适用于特定产品,则该字段应为空或为 null。
product_id
product_name
...
color (red, blue)
size (null)
some other option (23, 24, 24)
another option (null)
我在创建这个 MySQL 查询时遇到了困难,如果有任何帮助,我将不胜感激。
最佳答案
我很确定您将无法通过单个查询来完成此操作,或者您的查询将包含一些子查询。
我遇到了同样的问题,不得不创建一个单独的类。首先,它获得一个产品数组(列表),然后迭代产品列表、请求的功能列表,包括每个产品的功能名称和值。
在某些情况下,在一个类中创建多个方法并“逐步”获取数据比尝试进行单个复杂查询更容易。
保持简单,祝你好运。
关于mysql - osCommerce mysql 导出到 Excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33882371/