gpt4 book ai didi

mysql - prestashop : MySQL Query For product features

转载 作者:行者123 更新时间:2023-11-30 00:42:31 25 4
gpt4 key购买 nike

我需要在 prestashop 1.5 中获取产品功能,但问题是我使用了一项修改,使我能够为每个产品的一项功能赋予多个值

示例:

兼容的存储卡: - 记忆录 xD - 内存棒 - 内存棒PRO - 多媒体卡 (MMC) - Carte 安全数字 (SD)

我收到这个查询:

Select fl.name, fvl.value, f.id_feature
From ps_feature_lang fl Left Join
ps_feature_product fp On fl.id_feature = fp.id_feature And fp.id_product = 291
Left Join
ps_feature_value_lang fvl On fp.id_feature_value = fvl.id_feature_value And
fvl.id_lang = 5 Left Join
ps_feature f On f.id_feature = fl.id_feature
Where fl.id_feature In (Select ps__fc_categories_features.feature_id
From ps__fc_categories_features)
Group By fl.name, fvl.value, f.id_feature, fl.id_feature
Order By f.position

但是,如果给定产品的某个功能具有多个值,它将为该功能提供多个原始数据最好的是一个查询,它将连接具有多个值的每个特征的值

提前谢谢。

最佳答案

您应该能够通过对查询进行小幅调整来完成此操作。试试这个:

Select fl.name, group_concat(fvl.value) as values, f.id_feature
From ps_feature_lang fl Left Join
ps_feature_product fp
On fl.id_feature = fp.id_feature And fp.id_product = 291 Left Join
ps_feature_value_lang fvl
On fp.id_feature_value = fvl.id_feature_value And fvl.id_lang = 5 Left Join
ps_feature f
On f.id_feature = fl.id_feature
Where fl.id_feature In (Select ps__fc_categories_features.feature_id
From ps__fc_categories_features
)
Group By fl.name, fl.id_feature
Order By f.position;

此查询从 group by 中删除 fvl.value 并添加 group_concat() select。我还删除了 f.id_feature。根据加入条件,它似乎是多余的。

关于mysql - prestashop : MySQL Query For product features,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21647891/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com