[英]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.