MySQL巧妙利用help_topic表把以逗号分隔的字符串转换成行
脚本:
select substring_index(substring_index('82,83,84,85,86',',',help_topic_id+1),',',-1) as Id
from mysql.help_topic
where help_topic_id<(length('82,83,84,85,86')-length(replace('82,83,84,85,86',',',''))+1);
结果:
注意事项:
无法调用help.topic表,或者你的help.topic表为空。解决办法:任意找一个可读表,只需要id是从0或者1开始的自然数序列,既可以套进sql中,替代help.topic表