标签:dex 字段 nbsp 问题: substr bsp bst 11.2 str
问题:将一个IP地址字段分解到列中,考虑下面列出的IP地址:
111.22.3.4
要得到如下所示的查询结果:
+-----+----+---+---+
| a | b | c | d |
+-----+----+---+---+
| 111 | 22 | 3 | 4 |
+-----+----+---+---+
解决方案:
select substring_index(substring_index(y.ip,‘.‘,1),‘.‘,-1) a,
substring_index(substring_index(y.ip,‘.‘,2),‘.‘,-1) b,
substring_index(substring_index(y.ip,‘.‘,3),‘.‘,-1) c,
substring_index(substring_index(y.ip,‘.‘,4),‘.‘,-1) d
from (select ‘111.22.3.4‘ as ip from t1) y;
标签:dex 字段 nbsp 问题: substr bsp bst 11.2 str
原文地址:http://www.cnblogs.com/liang545621/p/6797321.html