mysql一行转多行、根据指定字符分割,还能看到分割成了几份
SELECT
substring_index(
substring_index(
`a`.`executor`,
',',(
`b`.`help_topic_id` + 1
)),
',',-(
1
)) AS `coop_branch`,
substr( `a`.`dispatch_list_datetime`, 1, 4 ) AS `dyear`,
substr( `a`.`dispatch_list_datetime`, 6, 2 ) AS `dmonth`,((
length( `a`.`executor` ) - length(
REPLACE ( `a`.`executor`, ',', '' ))) + 1
) AS `executor_count`,
a.*
FROM
(
`emp_cas`.`bm_dispatch_list` `a`
JOIN `mysql`.`help_topic` `b` ON ((
`b`.`help_topic_id` < (( length( `a`.`executor` ) - length( REPLACE ( `a`.`executor`, ',', '' ))) + 1 ))))