SQL 数据特殊符号切割

需求SQL 字段中的字符串拆成多行显示.

实现:MYSQL SUBSTRING_INDEX(COL1,'字符串分隔符号',位置)

SQL: select
 t2.help_topic_id as ID
 ,SUBSTRING_INDEX(SUBSTRING_INDEX(RecordIdentifier,' ',t2.help_topic_id+1),' ',-1) as RecordIdentifier 
,RecordIdentifier
,Substring_index(RecordIdentifier,' ',help_topic_id+1)
from
(select
extractvalue(t1.xml_content,'/DSExport/Job/Record/@Identifier') as RecordIdentifier
   from awm_job t1)
t1 left join mysql.help_topic t2
on t2.help_topic_id < LENGTH(t1.RecordIdentifier)-length(replace(t1.RecordIdentifier,' ',''))+1;

Result:

猜你喜欢

转载自blog.csdn.net/link200809/article/details/83412534