2017-06-13 2 views

Répondre

3

Utilisez l'opérateur ->>(Get JSON object field as text), par exemple

with my_table(id, json) as (
values 
(1, '{"key":95}'::json), 
(2, '{"key":90}'), 
(3, '{"key":50}') 
) 

select * 
from my_table 
where (json->>'key')::int >= 90; 

id | json  
----+------------ 
    1 | {"key":95} 
    2 | {"key":90} 
(2 rows)  
1

Si vous utilisez la version postgres> = 9.3, vous pouvez:

select * from t 
where (json->>'key')::numeric >= 90