programming/mysql
字符串转行modified | Saturday 28 June 2025 |
---|
字符串转行 help_topic GROUP_CONCAT
GROUP_CONCAT
mysql.help_topic
select GROUP_CONCAT(id) as ids from test
SET @ids = ‘4488,4489,4490,4491,4492,4493,4494’;
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(@ids, ‘,’, ht.help_topic_id + 1), ‘,’, -1) as id FROM mysql.help_topic ht
WHERE ht.help_topic_id < (LENGTH(@ids) - LENGTH(REPLACE(@ids, ‘,’, ‘’)) + 1);