[英]How can i fetch a parameter in jsonb column
I have a table like this我有一张这样的桌子
| id | reciever
| (bigint) |(jsonb)
------------------------------------------------------
| 1 | {"name":"ABC","email":"abc@gmail.com"}
| 2 | {"name":"DEF","email":"deef@gmail.com"}
How can I fetch name where id = 1
如何获取
name where id = 1
the output will be like this output 将是这样的
| id | name
------------------------------------------------------
| 1 | ABC
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 Check out other JSON operators and functions on the postgres documentation https://www.postgresql.org/docs/12/functions-json.html
You can run the following:您可以运行以下命令:
SELECT id, receiver->>'name' AS name
FROM mytable
WHERE id = 1;
The ->>
operator gets the text value from JSON data by the given key name. ->>
运算符通过给定的键名从 JSON 数据中获取文本值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.