命令应该做的:如果模式“*@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。
最佳答案
你是说
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/