Here is my table (simplified, only significant columns):
CREATE TABLE things (
id serial primary key
, name varchar
, blueprint json default '{}'
);
And some sample data:
# select * from things;
id | name | blueprint
----+---------+-----------------------------------------------------------------------------
1 | Thing 1 | {}
2 | Thing 2 | {"1":{"name":"Iskapola","wight":"2"}}
3 | Thing 3 | {"1":{"name":"Azamund","weight":"3"}, "2":{"name":"Iskapola","weight":"1"}}
4 | Thing 4 | {"1":{"name":"Ulamir","weight":"1"}, "2":{"name":"Azamund","weight":"1"}}
I'd like to select rows that have 'Azamund'
anywhere under the name
key.
Something like this:
# select * from things where * ->> 'name' = 'Azamund';
id | blueprint
----+----------------------------------------------------------------------------
7 | {"1":{"name":"Azamund","weight":"3"}, "2":{"name":"Iskapola","weight":"1"}}
8 | {"1":{"name":"Ulamir","weight":"1"}, "2":{"name":"Azamund","weight":"1"}}
Data is nested exactly like in the sample (only one level).
Currently we are using PostgreSQL 9.3.5.
Is it possible in PostgreSQL 9.3? Maybe 9.4?