PostgreSQL Nested JSON Querying -
At PostgreSQL 9.3.4, I have a JSON type column called "person" and the data stored in it is in the does not work Works < / Strong> Why type casting is necessary? Is not it disabled? Am I doing something wrong or is it necessary for postgrazon support? The reason for this is that the operator You are the operator {Dogs: [{Breed: & lt; & Gt;, Name: & lt; & Gt;}, {Breed: & lt; & Gt;, Name: & lt; & Gt;}]} I want to retrieve the dog breed at Index 0. Here are two questions:
db = & gt; Person- & gt; 'Dogs' - & gt; & Gt; 0-> Choose 'breed' from people where ID = 77; Error: Operator does not exist: Text - & gt; Unknown line 1: person- & gt; Select 'Dogs' - & gt; & Gt; 0-> 'Bree ... ^ Hint: An operator does not match given given name and logic type (fairs). You may need to explicitly enter
Select (person-> dogs' ->> 0) :: json- & gt; 'Breed' from es_config_app_solutiondraft where id = 77; ? Column? ----------- "Westli" (1 line)
- & gt; & Gt; JSON receives array elements as text, you need an artist to change its result back to JSON.
-> By selecting :
, you can eliminate this unnecessary artist-> person> & gt; 'Dogs' - & gt; 0-> 'Breed' to people where id = 77;
Comments
Post a Comment