Reputation: 51
BEGIN
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'MAX(IF(questions= ''',
questions,
''', yes_no, NULL)) AS ''',
questions,''''
)
) INTO @sql
FROM tbl_main where task=in_task;
SET @sql = CONCAT('SELECT case_id,audited_by,resolved_by, ', @sql, ' FROM tbl_main WHERE task IN (''',in_task,''') and audited_date between(''',from_date,''') and (''',to_date,''') GROUP BY case_id,audited_by,resolved_by');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END
Hi, I'm using the stored procedure and I'm converting row values to column headers dynamically , the stored procedure works fine if the row value is within 50 words or so and it fails when the row value is longer than 50 words . I don't know how to fix it. Can any one help me with this .
Upvotes: 2
Views: 53