【发布时间】:2014-08-17 18:31:05
【问题描述】:
我找到了这个 query:
CREATE TABLE tableA (string_a text);
INSERT INTO tableA(string_a) VALUES
('the manual is great'), ('Chicken chicken chicken'), ('bork');
CREATE TABLE tableB(candidate_str text);
INSERT INTO tableB(candidate_str) VALUES
('man'),('great'),('chicken');
SELECT string_a
FROM tableA
WHERE string_a LIKE ANY (SELECT '%'||candidate_str||'%' FROM tableB);
结果:
the manual is great
chicken chicken chicken
问题: 怎么做才能有这个新结果?
the manuel is great | great
chicken chicken chicken | chicken
【问题讨论】:
-
如果有多个匹配项,请定义从
tableB中选择的哪个行。另外,您希望每行匹配 few 还是 many?
标签: sql postgresql substring