如何对列 jsonb 类型使用通配符

how to use wildcard for a column jsonb type

--------------------------------------------------------------
ID   | Day              | ftfm_profile
--------------------------------------------------------------
23   |  22/10/2020      | {"name": ["EGMHTMA", "EGMHCR", "EDYYFOX2", "EGTTFIR", "EGTTEI"],"type": ["AUA", "ES", "ES", "FIR"]}
-------------------------------------------------------------------------------------------------
24   |  22/10/2020      | {"name": ["LFBBRL1", "LFBMC2", "LFBBTT6", "LFTTN8", "EGTTEI"],"type": ["AUA", "ES", "ES", "FIR"]}
-------------------------------------------------------------------------------------------------
25   |  22/10/2020      | {"name": ["LFBGTH4", "LFBMC2", "LFFFE7", "LFTTN8", "EGTTEI"],"type": ["AUA", "ES", "ES", "FIR"]}

我的 Postgres 数据库中有一个 table(命名配置文件),它有 3 列:ID、日期,Ftfm_profile 类型为 jsonb,我试图提取配置文件名称所在的行(ftfm_profile->'name') 以 'LFBB' (sql: LFBB%) 开头,使用通配符如下:

select * from public.profile where ftfm_profile ->'name' ? 'LFBB%'

预期结果:

-------------------------------------------------------------------------------------------------
24   |  22/10/2020      | {"name": ["LFBBRL1", "LFBMC2", "LFBBTT6", "LFTTN8", "EGTTEI"],"type": ["AUA", "ES", "ES", "FIR"]}
-------------------------------------------------------------------------------------------------

我似乎找不到解决方案,感谢您的帮助

一个选项在 exists 子查询中插入 json 数组:

select * 
from public.profile 
where exists (
    select 1
    from jsonb_array_elements_text(ftfm_profile ->'name') as e(name) 
    where e.name like 'LFBB%'
)