select
SUBSTRING_INDEX(phone#, ",", -1) as phone1,
SUBSTRING_INDEX(phone#, ",", 1) as phone2 from table1
where phone# like '%,%'
union all
select phone# as phone1, '' as phone2 fraon table1
where phone# not like '%,%'
SELECT concat(Substring(phone, 1, Locate(',', phone) - 1),' in phone1') AS
phone1,
concat(Substring(phone, Locate(',', phone) + 1),' in phone2') AS phone2
FROM tablename where phone not like '%,%'
3条答案
按热度按时间iswrvxsc1#
使用子字符串索引可以根据分隔符来显示字符串
只有当你知道要分隔多少时,这才适用
mzsu5hc02#
从样本数据,我觉得你需要以下
sz81bmfz3#
试试这个: