隔壁太冷,求个 postgres jsonb[] 类型 查询的问题

凌晨4点5杀老大爷 2016-01-11 09:21:42
隔壁的postgres 太冷清了,有搞过postgres 仁兄没,请教 当数据类型为 json[] 类型的时候 如何查询的问题 貌似是要用jsonArray 这方面资料太少
...全文
1518 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
简即美 2019-10-30
  • 打赏
  • 举报
回复
语法上没有问题,但是实际上json本身就支持数组,所有没有必要这样做。
  • 打赏
  • 举报
回复
引用 1 楼 ch21st 的回复:
大概是这个样子。下面的链接你可以参考下 http://michael.otacoo.com/postgresql-2/postgres-9-3-feature-highlight-json-parsing-functions/

postgres=# create table testjson(id serial, data json);
postgres=# insert into testjson (data) values('{"a": 1, "b": 2}'::json);
postgres=# insert into testjson (data) values('{"a": 3, "b": 4, "c": 5}'::json);
postgres=# insert into testjson (data) values('{"a": 6, "c": 7}'::json);
---
select * from testjson where (data->>'a')::int>1;
谢谢 已经搞定
道素 2016-01-13
  • 打赏
  • 举报
回复
大概是这个样子。下面的链接你可以参考下 http://michael.otacoo.com/postgresql-2/postgres-9-3-feature-highlight-json-parsing-functions/

postgres=# create table testjson(id serial, data json);
postgres=# insert into testjson (data) values('{"a": 1, "b": 2}'::json);
postgres=# insert into testjson (data) values('{"a": 3, "b": 4, "c": 5}'::json);
postgres=# insert into testjson (data) values('{"a": 6, "c": 7}'::json);
---
select * from testjson where (data->>'a')::int>1;

6,129

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 新技术前沿
社区管理员
  • 新技术前沿社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧