一行拆多行

select a.id, a.username, 
substring_index(substring_index(a.course, '|', b.help_topic_id + 1), '|', -1) course  
from student a JOIN mysql.help_topic b 
ON b.help_topic_id < (length(a.course) - length(REPLACE(a.course, '|', '')) + 1);

 

posted @ 2020-04-03 17:31  贝宝纸  阅读(104)  评论(0编辑  收藏  举报