Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 检查字符串是否是Postgres中jsonb数组中任何元素的子字符串_Sql_Postgresql_Jsonb - Fatal编程技术网

Sql 检查字符串是否是Postgres中jsonb数组中任何元素的子字符串

Sql 检查字符串是否是Postgres中jsonb数组中任何元素的子字符串,sql,postgresql,jsonb,Sql,Postgresql,Jsonb,我在Postgres数据库中有一列类型为jsonb。如何检查字符串是否是jsonb数组中任何元素的子字符串?理想情况下,解决方案也会忽略大写字母。尝试以下方法: with cte as ( select jsonb_array_elements('["hello", "world", "earth", "universe"]') as word from test ) select cte.word, position('wor' in cte.word::text) > 0 "

我在Postgres数据库中有一列类型为
jsonb
。如何检查字符串是否是jsonb数组中任何元素的子字符串?理想情况下,解决方案也会忽略大写字母。

尝试以下方法:

with cte as (
  select jsonb_array_elements('["hello", "world", "earth", "universe"]') as word
  from test
) 
select cte.word, position('wor' in cte.word::text) > 0 "isSubstr" 
from cte;
试试这个:

with cte as (
  select jsonb_array_elements('["hello", "world", "earth", "universe"]') as word
  from test
) 
select cte.word, position('wor' in cte.word::text) > 0 "isSubstr" 
from cte;

什么是
cte
,什么是
test
。我猜test是包含
jsonb
列的表,但什么是
cte
?@Roymunson确实如此详细,样本数据应该在问题中共享……什么是
cte
,什么是
test
。我猜测试是包含
jsonb
列的表,但什么是
cte
?@Roymunson确实如此,问题中应该共享样本数据。。。