Search Postgresql Archives

Re: Wildcarding json keys in json query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 30, 2021 at 1:40 PM David Gauthier <davegauthierpg@xxxxxxxxx> wrote:
{
ports : {
    port_abc:{min: 5, max: 7, mean: 6},
    port_def:{min: 5, max: 9, mean: 7},
    port_ghi:{min: 6, max: 10, mean: 8}
    }
}

select 1 from mytbl where cast(test_results#>'{ports,*,mean}' as float) >= 7 ;

But the "*" doesn't work :-(

Any ideas ?


If you have the option to not use data values in json field identifiers (i.e., object keys) you will avoid fighting against the system's underlying design choices.  i.e., IMO, ports should contain an array, not an object.

I was under the impression that SQL/JSON Path (jsonpath) functions/operators solve some of these kinds of problems so try using that instead of the "fixed structure" access-based functions and operators.

David J.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux