-
关于 postgreSQL 的 jsonb 字段里面的 id 关连其他表的 id 的问题
2019-01-23 16:22create table A(
packid jsonb
);create table B(
packid varchar(64)
);
insert into aimb.A values('["1","2"]');insert into aimb.B values('2');
select * from A
select * from B
select json_each(packid) from aimb.A
select ta.packid as Ap, tb.packid as Bp from
(select jsonb_array_elements_text(packid) as packid from aimb.A) ta
left join aimb.B tb on ta.packid = tb.packidselect tb.packid from
aimb.A ta
, aimb.B tb where ta.packid @> ('["' || tb.packid || '"]')::jsonb