我想执行查询但是要搜索多个关键字,例如
Select "Accession_Number" from Works where to_tsvector("Description") @@ to_tsquery('music') OR @@ to_tsquery('chair') OR to_tsquery('garb');
最好的方法是什么?
答案 0 :(得分:0)
我猜你的DDL看起来像这样:
create table Works
(
"Accession_Number" serial,
"Description" text,
primary key ("Accession_Number")
);
insert into Works
("Description")
values
('lorem ipsum dolor garb sit'),
('brown fox chases music'),
('hello do you remember me chair'),
('what is this Description');
要搜索特定关键字的多个列,您有多个选项。
以下查询显示了POSIX Regular Expressions
的使用情况select "Accession_Number",
"Description"
from Works
where "Description" ~ '(music|chair|garb)';
您还可以使用LIKE或SIMILAR TO。