I have a jsonb
column which has data as below.
[
{"key": "unit_type", "value": "Tablet", "display_name": "Unit Type"},
{"key": "pack_type", "value": "Packet", "display_name": "Pack Type"},
{"key": "units_in_pack", "value": "60", "display_name": "Units in Pack"},
{"key": "item_unit", "value": "", "display_name": "Item unit"},
{"key": "item_size", "value": "1", "display_name": "Item Size"},
{"key": "details", "value": "", "display_name": "Details"},
{"key": "slug", "value": "otc7087", "display_name": "Slug"}
]
I want to get the value
field from the array which has a key
called slug
, so that when I do a select query over table, I get this particular value from the column. For the above row when I do select name, slug, price from table
, I should get med1, otc7087, 100
as the output. I am unable to build a query for this thing. I can get all the keys or all the values but how do I select a particular one in the same select query?
Or simply how do I select just the slugs
from the table? That will answer.
{"unit_type": {"value": "Tablet", "display_name": "Unit Type"}, ...}
or something? – Dealatemed1
and100
come from? Some data not shown here? – Dealateslug
from the above column and these two or others will be in select statement. – Monstrance