gpt4 book ai didi

mysql - 获取多个产品属性作为 "catalog_product_entity"上的列

转载 作者:行者123 更新时间:2023-11-29 15:26:15 25 4
gpt4 key购买 nike

我正在尝试制作一个表格,显示具有各种产品属性的产品列表,但我完全无法做到这一点。

预期表如下所示;

entity_id, sku, price, cost
1, abc, 20, 15
2, def, 30, 25
3, ghi, 10, 5

下面的两个产品属性都存储在表“catalog_product_entity_decimal”的同一列“value”中

Price: attribute_id = 77

Cost: attribute_id = 81

因此,如果我内部连接表,每个entity_id 对于 attribute_id 77 和 81 有 2 行

你能帮我解决这个问题吗?

最佳答案

您可以两次加入属性表

select a.entity_id, a.sku, b.value price, c.value cost
from your_product_table a
inner join your_table_attribute b
on a.entity_id = b.entity_id
AND b.attribute_id = 77
inner join your_table_attribute c on a.entity_id = c.entity_id
AND c.attribute_id = 81
where a.entity_id = 1

关于mysql - 获取多个产品属性作为 "catalog_product_entity"上的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59069416/

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