M
M
McMike2018-06-20 07:18:11
PostgreSQL
McMike, 2018-06-20 07:18:11

How to select by value from jsonb field?

There is a field in the table with the jsonb type, in it, respectively, the structure {key1:value, key2:value, etc.}
How to write the following queries?
Select table columns and values ​​for field with key1
Select table columns where value key2 = given

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyacheslav Uspensky, 2018-06-22
@Kwisatz

select field1,
       jsonb_field -> 'key' as jsonb_value
from mytable
where jsonb_field @> '{"key":"value"}'

D
Diavert, 2014-10-24
@Diavert

How can I set the dropdown list in a cell to change when an item is selected from the first dropdown list in Google Docs Sheets?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question