MySql 如何将一张表中的电话字段分成两个单独表中的前缀/号码? [英] MySql How to separate a telephone field in one table into prefix / number in two separate tables?

查看:46
本文介绍了MySql 如何将一张表中的电话字段分成两个单独表中的前缀/号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个要求:从客户表中返回电话号码的前缀.我尝试通过将全名拆分为名字/姓氏来使用字符串,但它仅适用于数字.完整的 nb 格式为 (258) 1231456

I have this requierment: From Customers table –return the prefix for phone numbers. I tryed with strings as by splitting the fullname into first/last name but it works only the one for the number. The full nb format is (258) 1231456

推荐答案

根据理解你可以使用 substring(string,position,length) 为例

Base from what understand you can use substring(string,position,length) for example

SELECT SUBSTRING(phonenumbercolumn,1,3) AS prefix 
FROM customer;

这篇关于MySql 如何将一张表中的电话字段分成两个单独表中的前缀/号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆