【发布时间】:2021-07-14 16:50:22
【问题描述】:
我有一个类似于以下的数据库架构,其中有一个 Children 记录表
CREATE TABLE Children (
name varchar(100),
friends JSON NOT NULL,
);
INSERT INTO Children (name,friends)
VALUES('Sam',
array['{"name":"Rakesh","country":"Africa"}',
'{"name":"Ramesh","country":"India"}']::json[]);
现在我需要查询数据并仅在朋友的名字像'%Ra'时显示它。 JSON数据的结构是一致的。
【问题讨论】:
-
强制转换为
json[]对我来说毫无意义 - 它会导致错误“列“朋友”是 json 类型,但表达式是 json[] 类型"
标签: sql json postgresql