【发布时间】:2015-11-04 17:25:54
【问题描述】:
我在 PostgreSQL 中有一个字符串数组:
SELECT ARRAY['dog', 'cat', 'mouse'];
还有一大段:
Dogs and cats have a range of interactions. The natural instincts of each species lead towards antagonistic interactions, though individual animals can have non-aggressive relationships with each other, particularly under conditions where humans have socialized non-aggressive behaviors.
The generally aggressive interactions between the species have been noted in cultural expressions.
对于数组中的每个项目,我想检查它是否出现在我的大段落字符串中。我知道对于任何一个字符串,我都可以执行以下操作:
SELECT paragraph_text ILIKE '%dog%';
但是有没有一种方法可以同时检查数组中的每个字符串(对于任意数量的数组元素)而不使用 plpgsql?
【问题讨论】:
标签: sql arrays postgresql sql-like