好的,我在一个名为path的列上有一个有ltree的表。我想选择多条路径,但我不希望有大量的OR语句。这是可能的还是这是最好的方法?
路径:
查询:
SELECT content, path FROM threads WHERE path ~ 'schools.myschool.*' OR path ~ 'companies.about.*' OR path ~ 'testing.information.content.*
发布于 2014-03-11 08:21:30
select 'schools.myschool.*' ~ any(array[
'schools.myschool.*', 'companies.about.*', 'testing.information.content.*'
]);
?column?
----------
t发布于 2017-09-29 06:10:23
您可以使用or-操作符|将正则表达式连接到一个表达式中,并通过分隔公共后缀:
SELECT content, path FROM threads
WHERE path ~ '(schools.myschool|companies.about|testing.information.content).*'https://stackoverflow.com/questions/22315962
复制相似问题