¿Cómo trabajar con postgresql JSON donde las claves son arbitrarias?
Frecuentes
Visto 188 equipos
4
I have a JSON field c1 in a table t1 which is of form
{
"11111" : { "STATUS" : "1"},
"22222" : { "STATUS" : "0"},
"33333" : { "STATUS" : "0"}
}
I want find those row of t1 in which any keys status is 1, I have tried below command
with r1 as(select t1.*, json_object_keys(c1) as keys from t1) select * from r1 where r1.c1->keys->>'STATUS' = '1';
but it is not giving me any row?
1 Respuestas
2
select *
from t1
where exists (
select 1
from json_each(c1)
where value ->> 'STATUS' = '1'
)
Respondido 12 Feb 14, 10:02
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas sql json postgresql postgresql-9.3 or haz tu propia pregunta.