我正在尝试创建一个MySQL查询,它将Prestashop上的产品属性列在一行中(我不想依赖付费模块)。
当前查询是:
SELECT
p.id_product AS 'idProduto',
pac.id_attribute,
al.name 'Nome_SKU',
pa.id_product_attribute as 'idSKU',
pl.name AS 'Nome',
pl.description_short AS 'Descricao Curta',
pl.description AS 'Descricao',
pl.meta_title AS 'Meta-Title',
pl.meta_keywords AS 'Meta-keyword',
pl.meta_description AS 'meta-description',
pl.link_rewrite AS 'URL rewrite',
pl.available_now AS 'texto_estoque',
pl.available_later AS 'texto_indisponivel',
pa.quantity as 'Quantidade',
p.price 'Preco',
pa.minimal_quantity 'Quantidade Minima',
p.active AS 'Ativo (0/1)'
FROM
ps_product p
INNER JOIN
ps_product_lang pl ON p.id_product = pl.id_product
INNER JOIN
ps_product_attribute pa ON pl.id_product = pa.id_product
INNER JOIN
ps_product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute
INNER JOIN
ps_attribute_lang al ON al.id_attribute = pac.id_attribute
where pl.id_lang = 6
AND p.id_product = 101
group by pa.id_product_attribute,al.name
它的结果是这样的(即id_product 101):
我需要的是他们的idSKU在同一行中“分组”的结果,以便在一列中显示每个值(Nome_SKU),就像这样(即idSKU 647):