Haneef Puttur

Creating MYSQL View – Converting multiple Row data into single column separated by unique passport number

Main Table

 

CREATE VIEW gcse_result AS

SELECT  `gcse_passport` as passportno , GROUP_CONCAT(  ‘(‘,  `gcse_subject` ,  ‘/’,  `gcse_level` ,  ‘/’,  `gcse_result` ,  ‘)’

SEPARATOR  ‘, ‘ ) as Results

FROM  `gcse`

WHERE  `gcse_subject` IS NOT NULL AND  `gcse_level` IS NOT NULL AND  `gcse_result` IS NOT NULL

GROUP BY  `gcse_passport`

 

gcse_result

 

 

.

Exit mobile version