Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL跨表正则表达式匹配_Mysql_Regex_Join - Fatal编程技术网

MySQL跨表正则表达式匹配

MySQL跨表正则表达式匹配,mysql,regex,join,Mysql,Regex,Join,我有一个web应用程序,我正在开发一个分析引用的引擎 现在,我有了一个带有页面视图和参考的表,看起来像这样: pv_id referer ------------------------------------------------------------ 5531854534 http://www.google.com/search?ie=UTF-8... 8161876343 http://google.cn/search?search=human+rights 84

我有一个web应用程序,我正在开发一个分析引用的引擎

现在,我有了一个带有页面视图和参考的表,看起来像这样:

pv_id        referer
------------------------------------------------------------
5531854534   http://www.google.com/search?ie=UTF-8...
8161876343   http://google.cn/search?search=human+rights
8468434831   http://search.yahoo.com/search;_...
第二个表包含以下源定义:

source       regex
------------------------------------------------------------
Google       ^https?:\/\/[^\/]*google\.([a-z]{2,4})(\/.*)?$
Yahoo        ^https?:\/\/[^\/]*yahoo\.com(\/.*)?$
我想要的是Join在这两个表中创建的第三个表:

pv_id        source
------------------------------------------------------------
5531854534   Google
8161876343   Google
8468434831   Yahoo
如何用正则表达式连接这些表

更新:

将正则表达式的最后一部分从\/.*更改为\/.*?

尝试以下操作:

select t1.pv_id, t2.source
from table1 t1
  inner join table2 t2 on (t1.referer regexp t2.regex)
MySQL:

SELECT a.pv_id, b.source 
FROM a, b
WHERE a.referer REGEXP b.regex

正则表达式末尾的管道在做什么?右起第三个字符?最后一个圆括号选择\/.*部分的/something,或者管道后必须为空:这些正则表达式在正则表达式编辑器中工作。但我会在没有管道的情况下尝试。我将parentese更改为\/.*?现在可以用了,谢谢!这是行不通的。选择'http://www.google.com/“REGEXP”^https?:\/\/[^\/]*google\.com\/.*.\$”给了我1139-从REGEXP中获取了错误“空子表达式”。我的正则表达式可能有问题?