duanhuiuw12555 2014-06-09 04:55
浏览 616
已采纳

将jsonb列值转换为PostgreSQL中的多个列

lets say i have a table in PostgreSQL with the following columns:

CREATE TABLE sample
(
id int,
jsonb jsonb,
date date
)

and i inserted this two rows:

INSERT INTO sample
(id,jsonb,date)
VALUES
(1, '{"a":"a","b":"b"}', '2014/01/06'),
(2, '{"a":"a","b":"b"}', '2014/01/06')

i want to convert the above rows into this(doing a select in PostgreSQL):

1,"a","b",'2014/01/06'
2,"a","b",'2014/01/06'

to call in php json_encode(rows from sample)

and get something like this:

[{"id":1,"a":"a","b":"b","date":"2014/01/06"},
{"id":2,"a":"a","b":"b","date":"2014/01/06"}]

but now if i call in php json_encode(rows from sample) i get this:

[{"id":1,"jsonb":"{"a":"a","b":"b"}","date":"2014/01/06"},
{"id":2,"jsonb":"{"a":"a","b":"b"}","date":"2014/01/06"}]

hope someone can help me to handle that, thanks to everyone

  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 dataframe 某列数据分列
      • ¥15 风扇导入fluent后仿真压力和速度数据卡在旋转域
      • ¥15 echarts中dataZoom报错
      • ¥15 求解答:《前端综合基础》作为一门课程的话,应该包含哪些内容?
      • ¥15 软件原型系统开发+实例测试
      • ¥50 C#上位机调试Win USB
      • ¥15 java基础望榜榜 java基础望榜榜
      • ¥15 comsol 周期性端口
      • ¥15 unity导出微信小游戏的测试中双击未响应
      • ¥15 SPI驱动LORA接收端RF_BUSY