postgresql数据库json字段查询

select x.variable::json->>'imageId' as imageId, x.status, y.image_name 
from task x join image y on x.variable::json->>'imageId' = y.image_id
where x.variable::json->>'imageId' is not null and x.status is not null and y.is_valid is true;

其中,task表中的 variable 字段为一个json字符串,通过 

x.variable::json->>'imageId'

取得json串中的image字段,并作进一步处理。

猜你喜欢

转载自blog.csdn.net/haiyoung/article/details/79939529