gpt4 book ai didi

php - Postgresql - 根据 Json 值获取不同的记录

转载 作者:行者123 更新时间:2023-11-29 13:23:07 25 4
gpt4 key购买 nike

Scenario: I have table having the value stored in Json format on its one of the column.I'm expecting the result to get the Distinct or Unique Records on the basis of value (one of the value of json column value) stored in format of json.

My table have 3 columns :
1. Id (integer)
ex. value - 20
2. Description (text)
ex.value - {"first_name":"John","last_name":"Doe","company_id":"26"}
3. Created (integer)

现在我想要基于 company_id 值的不同记录,PostgreSQL 中是否有任何函数可以满足此类要求?

技术信息:

Postgresql version - 9.5

最佳答案

Postgres 9.5(以及一些更早的版本)有一些对查询 JSON 文本的内置支持。尝试以下查询:

SELECT *
FROM yourTable
WHERE Description->>'company_id' = 'some_value'

Documentation

关于php - Postgresql - 根据 Json 值获取不同的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38196819/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com