简体   繁体   English

想从 mysql db 中的电话号码中获取国家区号

[英]want to get country area code from phone number present in mysql db

I'm having phone number 1212010089 and want to know from which country I'm getting this number.I do have a table_1 which is having column1 area_code where lots of area codes are available and column2 location which is having an equivalent location according to that area_code the maximum length of area_code is 7 in it so please suggest me an appropriate sql query by which I can find the location from that number.我的电话号码是1212010089 ,想知道我是从哪个国家/地区收到这个号码的。我确实有一个table_1 ,它有 column1 area_code ,其中有很多区号可用,column2 location根据该位置具有等效位置area_code area_code最大长度是 7 所以请建议我一个合适的 sql 查询,通过它我可以从那个号码找到location Thanks in advance.提前致谢。

Try something like:尝试类似的东西:

SELECT location
FROM table_1
WHERE '237690000000' LIKE CONCAT(area_code,'%')
AND LENGTH(area_code)=
(SELECT MAX(LENGTH(area_code))
FROM table_1
WHERE '237690000000' LIKE CONCAT(area_code,'%'));

See Demo on DB-SQL Fiddle .请参阅DB-SQL Fiddle 上的演示

you can also try this:你也可以试试这个:

SELECT location FROM table_1 WHERE '23769111111' LIKE CONCAT(area_code,'%') ORDER BY LENGTH area_code DESC LIMIT 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MySQL:从电话号码中删除国家代码的 SQL - MySQL: SQL to remove country code from phone number PHP:使用MySQL数据库将区号与电话号码分开 - PHP: Separate Area Code from Phone number with MySQL Database 有什么方法可以从php中的电话号码中找到国家代码吗? - Is there any way to find country code from phone number In php? 从excel文件中如何获取特定国家/地区的最高汇率,然后将其添加到mysql数据库中 - from excel file how i get max rate for a specific country and after that add it to the mysql db 使用mysql db中的数据在html表中显示给定时间的活动并发进程数 - Use data from mysql db to present the number of active concurrent processes at a given time in a html table 在SQL MySQL 5.1上查询-查找具有特定区号的电话号码 - query on sql MySQL 5.1 - find phone numbers with specific area code 从国家/地区下拉框中存储国家/地区ID,但在db中将其存储为0 - store the country ID from country drop down box in mysql but it is storing as 0 in db Mysql:从数据库获取结果,知道我们不想获取特定 ID - Mysql : Get results from DB knowing that we don't want to get specific ids 如何输入地区和国家/地区代码 - How do i put area and country code 带街道地址的Mysql DB-我要按名称排序然后按数字排序? - Mysql DB w/Street Addresses - I want to Sort by Name then Number?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM