The select in mysql is this:
SELECT v.product_id,
nome AS Produto,
presentation AS Descricao,
presentation AS Descricao2,
name1 AS categoria,
description_two AS descricao,
price AS preco,
quantity AS estoque,
width,
height,
depth,
weight,
name,
referencecode,
datapostagem
FROM variant v
INNER JOIN productcategory p
ON v.product_id = p.product_id
INNER JOIN product
ON product.id = p.product_id
INNER JOIN category
ON category.id = category_id
INNER JOIN image i
ON i.product_id = p.product_id
INNER JOIN descriptiongroup D
ON D.product_id = p.product_id
INNER JOIN stock S
ON S.variant_id = v.id
INNER JOIN dimensiongroup G
ON G.variant_id = v.id
LIMIT 10
The result return lot of duplicate product_id
, how can I separate the product_id
in another column? Like product2, product3, product4 ?
If I do that select it shows me the correct form but just for one result, how can I join this select below in my main select?
select
product_id,
sum(case when presentation = 'Unitário = R$ 11,90 ' THEN price END) product_id1,
sum(case when presentation = '5 Pe?as = R$ 5,00 cada' THEN price END) product_id2,
sum(case when presentation = 'Bluesky Todas' THEN price END) product_id3
from
Variant
where
product_id = 1604
The result is:
product_id product_id1 product_id2 product_id3
1604 11.9 25 15
How can I make it dynamic, to show me all results not just for one?
The image of result below:
enter image description here
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…