如果楼主是mysql 这篇文章应该有一定的帮助:cnblogs.com/ants_double/p/11088864.html
如果是sqlserver 这篇文章应该可以的 https://www.cnblogs.com/51net/archive/2013/01/14/2859848.html
语句大致是这样:
select
a.id,b.school
from
(select id,school=convert(xml,' <root> <v>'+replace(school,',',' </v> <v>')+' </v> </root>') from Tab)a
outer apply
(select school=C.v.value('.','nvarchar(100)') from a.school.nodes('/root/v')C(v))b
回答很全面,你这个方法我试了可以,但我还发现了一个更好的方法
select oth
select oth
from table_name A1
lateral view explode(A1.School, ',') as oth
;
over
lateral view是hive的,oracle 是
select regexp_substr(school, '[^,]', 1, level) as sch
from table_name
connect by level <= regexp_count(school, '[^,]')
AND (prior dbms_random.values) is not null ;