![](/img/trans.png)
[英]How to fetch record from Postgres jsonb column with case insensitive manner?
[英]How can i fetch a parameter in jsonb column
我有一张这样的桌子
| id | reciever
| (bigint) |(jsonb)
------------------------------------------------------
| 1 | {"name":"ABC","email":"abc@gmail.com"}
| 2 | {"name":"DEF","email":"deef@gmail.com"}
如何获取name where id = 1
output 将是这样的
| id | name
------------------------------------------------------
| 1 | ABC
使用->>
运算符:
select id, receiver ->> 'name' as name
from the_table
where id = 1;
select id, receiver->'name'
from mytable
where id = 1
Check out other JSON operators and functions on the postgres documentation https://www.postgresql.org/docs/12/functions-json.html
您可以运行以下命令:
SELECT id, receiver->>'name' AS name
FROM mytable
WHERE id = 1;
->>
运算符通过给定的键名从 JSON 数据中获取文本值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.