SELECT
(@i:=@i+1) id,
a. NAME,
substring_index(
substring_index(
a.shareholder,
',',
b.help_topic_id + 1
),
',' ,- 1
) AS shareholder
FROM
company a
JOIN mysql.help_topic b ON b.help_topic_id < (
length(a.shareholder) - length(
REPLACE (a.shareholder, ',', '')
) + 1
),
(SELECT @i:=0) as i