Create Procedure `SelectProduct` (IN prod VARCHAR(70))
BEGIN
SET @sql = null;
SELECT GROUP_CONCAT(DISTINCT CONCAT( 'max(case when Attribute = ''',Attribute,'" Then p.Attributevalue end) as `',Attribute,'`' )
INTO @sql FROM tblAttribute;
SET @sql = CONCAT('Select pr.product, ',@sql,' from tblproduct tblproduct pr LEFT JOIN tblproductattribute p using(productid) left join tblattribute a using (attributeid)
where pr.product LIKE (''%',prod,'%'') group by pr.productid ');
Prepare st from @sql;
execute stmt;
END
Please help me,the procedure about output columns like this
|Product|Width|Color|Size|
what i need is like this
|Product|Product description|
sampleproduct|13mm,Green,Small