我想运行查询
SELECT * FROM table_a JOIN table_b ON table_a.title LIKE ('^[a-b]' || table_b.title)其中,如果table_a.title =“foo bar",并且table_b.title具有名为"oo”的行,则查询不会返回任何结果,但如果table_b.title具有名为"foo“的行,则将返回结果。
基本上,我只想匹配table_b上的标题,如果它是一个完整的单词(由空格包围,或者在字符串的开头和结尾),而不是如果另一个单词中包含table_b.title的一部分。
有什么想法吗?
发布于 2017-02-16 13:05:33
如果要在Postgres中使用正则表达式,请使用~、similar to或regexp_matches,而不是like
SELECT *
FROM table_a JOIN
     table_b
     ON table_a.title ~ ('^[a-b]' || table_b.title);https://stackoverflow.com/questions/42263906
复制相似问题