sql - Postgres : regex and nested queries something like Unix pipes

标签 sql regex postgresql

命令应该做的:如果模式“*@he.com”在不包括标题的行上,则输出 1:

 user_id | username |   email   |           passhash_md5           | logged_in | has_been_sent_a_moderator_message | was_last_checked_by_moderator_at_time | a_moderator 
---------+----------+-----------+----------------------------------+-----------+-----------------------------------+---------------------------------------+-------------
       9 | he       | he@he.com | 6f96cfdfe5ccc627cadf24b41725caa4 |         0 |                                 1 | 2009-08-23 19:16:46.316272            | 

简而言之,我想将许多 SELECT 命令与 Regex 连接起来,就像 Unix 管道一样。上面的输出来自 SELECT 命令。与模式匹配的新 SELECT 命令应该给我 1。

Related

最佳答案

你是说

SELECT regexp_matches( (SELECT whatevername FROM users WHERE username='masi'), 'masi');

您显然不能将记录 (*) 提供给 regexp_matches,但我认为这不是您的问题所在,因为您提到了嵌套 SQL 查询的问题在主题中。

也许你的意思是类似

SELECT regexp_matches( wn, 'masi' ) FROM (SELECT whatevername AS wn FROM users WHERE username LIKE '%masi%') AS sq;

对于您的子查询产生多个结果的情况。

关于sql - Postgres : regex and nested queries something like Unix pipes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1320721/

相关文章:

php - 正则表达式 - 阻止垃圾邮件

Python odo CSV 到 SQL - 没有这样的文件或目录

postgresql - 引发并捕获用户定义的异常

mysql - 过滤掉非零值,除非该值是其组中唯一的值(SQL 或 R)

sql - db2 中有 'greatest' 函数吗?

regex - 使用正则表达式从 postgres 中的多行条目中修剪文本

php - 正则表达式抓取最后一场比赛之后的所有文本

java - 创建一个休息服务来调用和执行一个 postgres 函数

mysql - 添加带有更新级联的外键

sql - 在没有 DUAL 表的情况下使用 SYSDATE()