Answer the question
In order to leave comments, you need to log in
How to get key by value in JSONB?
The jsonb field contains the following structure:
{
"1552461856.244": 13,
"1552461716.1383": 0,
"1552461717.0405": 3,
"1552462001.1221": 4,
"1552462003.4729": 1,
"1552702001.1221": 4
}
Answer the question
In order to leave comments, you need to log in
It is wrong to use jsonb when you need to find a key by value. This is the wrong approach.
Instead of jsonb, you need to use 2 fields and then you can search for records
select col_key from table
where col_val=4
order by col_key desc
limit 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question