ELECT
a.Included_time,
SUBSTRING_INDEX( SUBSTRING_INDEX( a.file_codes, ',', b.help_topic_id + 1 ), ',',- 1 ) AS ids
FROM
document_flow_master AS a
JOIN mysql.help_topic AS b ON b.help_topic_id < ( LENGTH( a.file_codes ) - LENGTH( REPLACE ( a.file_codes, ',', '' ) ) + 1 )
WHERE
a.deleted = 0
GROUP BY (SUBSTRING_INDEX( SUBSTRING_INDEX( a.file_codes, ',', b.help_topic_id + 1 ), ',',- 1 ) )
ORDER BY
a.Included_time