MySQL数据库SUBSTRING_INDEX的运用
一、如何运用SUBSTRING_INDEX截取address的省市区
二、应用SUBSTRING_INDEX函数进行多次嵌套截取
SELECT SUBSTRING_INDEX(t1.`address`, '_', '1') AS '国家', SUBSTRING_INDEX( ( SUBSTRING_INDEX(t1.`address`, '_', '2') ), '_', - 1 ) AS '省', SUBSTRING_INDEX( ( SUBSTRING_INDEX(t1.`address`, '_', '3') ), '_', - 1 ) AS '市', SUBSTRING_INDEX(t1.`address`, '_', '-1') AS '区' FROM user1 t1;