MYSQL通过SQL语句提取表中URL数据的域名 | 您所在的位置:网站首页 › sql数据提取语句 › MYSQL通过SQL语句提取表中URL数据的域名 |
MYSQL通过SQL语句提取表中URL数据的域名:
举例: https://www.baidu.com/s?ie=UTF-8&wd=123 > www.baidu.com http://www.baidu.com/s?ie=UTF-8&wd=123 > www.baidu.com select SUBSTR((REPLACE(REPLACE('https://www.baidu.com/s?ie=UTF-8&wd=123','https://',''),'http://','')), 1, INSTR((REPLACE(REPLACE('https://www.baidu.com/s?ie=UTF-8&wd=123','https://',''),'http://','')),'/')-1)如果做统计: select SUBSTR((REPLACE(REPLACE(url,'https://',''),'http://','')), 1, INSTR((REPLACE(REPLACE(url,'https://',''),'http://','')),'/')-1) host1, count(1) from dbo.table1 group by SUBSTR((REPLACE(REPLACE(url,'https://',''),'http://','')), 1, INSTR((REPLACE(REPLACE(url,'https://',''),'http://','')),'/')-1) order by count(1) desc
|
CopyRight 2018-2019 实验室设备网 版权所有 |