使用sqlite json函数,我想检索附近的值的价值基础
可以说我有这个JSON,我想检索名称等于数组键中的Chris的所有年龄值。
{
"Array": [
{
"age": "65",
"name": "Chris"
},
{
"age": "20",
"name": "Mark"
},
{
"age": "23",
"name": "Chris"
}
]
}
该JSON存在于我的数据库内的JSON列中。 这样,我想检索一个年龄栏的年龄为65岁和23岁,因为他们都命名为克里斯(Chris)。
Lets say I have this Json and I would like to retrieve all the age values where the name equals Chris in the Array key.
{
"Array": [
{
"age": "65",
"name": "Chris"
},
{
"age": "20",
"name": "Mark"
},
{
"age": "23",
"name": "Chris"
}
]
}
That Json is present in the Json column inside my database.
by that I would like to retrieve one age column the has the age 65 and 23 because they both named Chris.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
json_each()
table-valuew表格的JSON数组的名称和年龄和 /code> 功能要过滤
'Chris'
的行,并确保他的年龄:更改
col
到JSON列的名称。请参阅
Use
json_each()
table-valued function to extract all the names and ages from the json array of each row of the table andjson_extract()
function to filter the rows for'Chris'
and get his age:Change
col
to the name of the json column.See the demo.