With this SQL I can in my database select and group products by variations that would in this case be different attributes for the same product.
So, when generating the view of the product, I have a dropdown in the product with all the attributes and the customer can choose in a greater number of possibilities for the same product, for example a car that has several colors.
Here's SQL :
$BuscaProdutosAtivos = $pdo->prepare("SELECT tbl_produtos.*, tbl_categorias.*,
GROUP_CONCAT(tbl_variacoes.valor) AS Variacoes FROM tbl_variacoes
INNER JOIN tbl_produtos ON tbl_produtos.id = tbl_variacoes.cod_prod
INNER JOIN tbl_categorias ON tbl_produtos.prod_categoria = tbl_categorias.cat_id
GROUP BY (tbl_produtos.id)");
With this SQL I return from tbl_variacoes
to column valor
. I would like to return valor
, dimensao
, quantidade
because these three information will be concatenated within the dropdown by forming a variation . How can I do this using this SQL ?
I figured if I could use several GROUP_CONCAT
but searching in some places I saw that it should not be done that way.