私は次のものを持っています:
SELECT *
FROM (
SELECT '{"people": [{"name": "Bob", "occupation": "janitor"}, {"name": "Susan", "occupation": "CEO"}]}'::jsonb as data
) as b
WHERE data->'people' @> '[{"name":"Bob"}]'::jsonb;
オブジェクト '{"name": "Bob", "occupation": "janitor"}' をフィルタリングしています
ボブの職業 (「用務員」) を返すにはどうすればよいですか?
SELECT data->'people'->>'occupation'
FROM (
SELECT '{"people": [{"name": "Bob", "occupation": "janitor"}, {"name": "Susan", "occupation": "CEO"}]}'::jsonb as data
) as b
WHERE data->'people' @> '[{"name":"Bob"}]'::jsonb;
戻り値
?column?
--------
NULL
探している:
occupation
----------
janitor