Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900