My Postgres version: 10.9
Using JsonB Column type which has a below structure:
columnName: favorites
{
"favouriteCity": "Boston",
"favoriteColors": ["Blue", "Red", "Green"],
}
Now, I want to filter all records which have favorite colors as Blue assigned.
I tried the below queries, but it didn't work.
select *
from r_fav
where favorites->>'favoriteColors' in ('Blue', 'Red')
or
jsonb_array_elements_text(favorites->>'favoriteColors' @>'Blue', 'Red')
Any idea how can I filter this?