Use GROUP_CONCAT
on selected COLUMN_NAME
that have same INDEX_NAME
.
SELECT
CONCAT (
'create index ', index_name, ' on ', table_schema, '.', table_name,
' ( ', GROUP_CONCAT( COLUMN_NAME SEPARATOR ', ' ), ' );'
) indexes_scripts
FROM
inf_schema.STATS
WHERE
table_schema='employee'
AND table_name='FILESPROC'
AND index_name NOT LIKE 'PRIMARY'
GROUP BY index_name