SELECT
SUBSTRING_INDEX(SUBSTRING_INDEX(‘2016,2017,2018,2019,2020‘,‘,‘,help_topic_id+1),‘,‘,-1) AS num
FROM
mysql.help_topic
WHERE
help_topic_id < LENGTH(‘2016,2017,2018,2019,2020‘)-LENGTH(REPLACE(‘2016,2017,2018,2019,2020‘,‘,‘,‘‘))+1
mysql.help_topic 这是使用了这个表的主键,因为它是连续的,不会中断的,也可以换成任意一个相似的表
原文:https://www.cnblogs.com/forthelichking/p/11818182.html