Sql拆分以逗号分隔字段单条数据变多条

SELECT
	`d`.`corp_id` AS `corp_id`,
	`d`.`user_id` AS `user_id`,
	`d`.`user_name` AS `user_name`,
	`d`.`act_state` AS `act_state`,
	`d`.`user_phone` AS `user_phone`,
	`d`.`csv_update_time` AS `csv_update_time`,
	`d`.`sys_work_date` AS `sys_work_date`,
	substring_index(
		substring_index(
			`d`.`dept_id`,
			',',(
				`b`.`help_topic_id` + 1 
			)),
		',',-(
			1 
		)) AS `dept_id`,
	`d`.`unicom_user` AS `unicom_user`,
	`d`.`broadband` AS `broadband` 
FROM
	(
		`dt_sys_corp` `d`
	JOIN `mysql`.`help_topic` `b` ON ((
	`b`.`help_topic_id` < (( length( `d`.`dept_id` ) - length( REPLACE ( `d`.`dept_id`, ',', '' ))) + 1 ))))

你可能感兴趣的:(SQL,sql)