Merging Concatenating JSON(B) columns in query

后端 未结 10 1540
不思量自难忘°
不思量自难忘° 2020-12-08 09:40

Using Postgres 9.4, I am looking for a way to merge two (or more) json or jsonb columns in a query. Consider the following table as an example:

10条回答
  •  旧巷少年郎
    2020-12-08 10:15

    Try this, if anyone having an issue for merging two JSON object

    select table.attributes::jsonb || json_build_object('foo',1,'bar',2)::jsonb FROM table where table.x='y';
    

提交回复
热议问题