举例:
id | value |
1 | 1,2,3,4 |
2 | 2,3,4,5,6 |
拆分成:
id | value |
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
SELECT DISTINCT SUBSTRING_INDEX( SUBSTRING_INDEX( tr.`sign_id`, ',', b.help_topic_id + 1 ), ',' ,- 1 ) xxx_id FROM youTableName ytn JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH(ytn.`xxx_id`) - LENGTH(REPLACE (ytn.`xxx_id`, ',', '')) + 1 )
说明:
DISTINCT:去重复操作
ytn.`xxx_id`:表别名.需要拆分的字段名
youTableName ytn:表名 别名
help_topic:自增长表