I created a table named 'delivery' and one of its field is an array of JSON.
CREATE TABLE delivery
(
id text NOT NULL,
date timestamp with time zone NOT NULL,
items json NOT NULL,
CONSTRAINT delivery_pkey PRIMARY KEY (id)
)
And here are the example data:
"1", "2012-01-08 20:54:38.541989+00", "[ {"id":1, "qty": 10 }, {"id":2, "qty": 300}]"
"2", "2012-01-08 22:44:10.016285+00", "[ {"id":1, "qty": 200}]"
How can I get the rows where the 'id' within the 'items' field is equal to 1?