The HTML content of my page is located in a LONG_TEXT column in MySQL.
我的页面的HTML内容位于MySQL的LONG_TEXT列中。
My objectif is to extract the url of my facebook page using the LOCATE
, SUBSTRING
or SUBSTRING_INDEX
functions in MySQL
我的目标是使用MySQL中的LOCATE,SUBSTRING或SUBSTRING_INDEX函数提取我的facebook页面的url
I found this article Mysql query to extract domains from urls but it doesn't really fit the problem.
我发现这篇文章是Mysql查询从url中提取域名,但它并不适合这个问题。
How would you extract efficiently the string between 'href="http://www.facebook.com/'
and '"'
in the string using mysql?
你如何使用mysql有效地提取字符串中'href =“http://www.facebook.com/'和'”'之间的字符串?
1 个解决方案
#1
1
This solution works but can certainly be improved
该解决方案有效,但肯定可以改进
IF(LOCATE('http://www.facebook.com/', html_cache) > 0, CONCAT('http://www.facebook.com/', SUBSTRING_INDEX((SUBSTRING_INDEX(html_cache, 'http://www.facebook.com/', -1)), '"', 1)), html_cache) AS page_url
#1
1
This solution works but can certainly be improved
该解决方案有效,但肯定可以改进
IF(LOCATE('http://www.facebook.com/', html_cache) > 0, CONCAT('http://www.facebook.com/', SUBSTRING_INDEX((SUBSTRING_INDEX(html_cache, 'http://www.facebook.com/', -1)), '"', 1)), html_cache) AS page_url