【发布时间】:2021-07-05 03:23:42
【问题描述】:
有这样一个数据结构:
Column "recipient" type jsonb
{
"phoneNumbers": [
{
"isDefault": true,
"type": "MOBILE",
"number": "3454654645"
},
{
"isDefault": true,
"type": "MOBILE",
"number": "12423543645"
}
]
}
我需要按数字编写搜索请求。在 postgres 文档中,我没有在数组中找到按值搜索,只有通过索引获得。不适合我
我做了一个这样的查询,它被执行了,但是还有其他方法可以搜索数组吗?
SELECT *
FROM my_table
WHERE recipient -> 'phoneNumbers' @> '[{"number":3454654645}]'
【问题讨论】:
标签: sql arrays json postgresql jsonb