我的数据采用数组格式,例如[1,2,3]如何与另一个表联接。这是我正在尝试的查询:
select
RCM.header_details->'auditAssertion'as auditassertion
from masters."RCM" RCM
left join reference."AUDIT_ASSERTION_APPLICATION" as AAA on AAA.id=RCM.header_details->'auditAssertion'
答案 0 :(得分:0)
您可以使用?
运算符检查值是否属于json(b)数组:
select m.header_details->'auditAssertion'as auditassertion
from masters.rcm m
left join reference.audit_assertion_application a
on m.header_details->'auditAssertion' ? a.id::text
为了提高性能,Postgres将支持以下索引:
create index on masters.rcm using gin ((header_details->'auditAssertion'));