Skip to content

Instantly share code, notes, and snippets.

@JuanRamino
Last active November 3, 2021 08:28
Show Gist options
  • Save JuanRamino/8e798dd42bb3b6800fce5ce4cc861c69 to your computer and use it in GitHub Desktop.
Save JuanRamino/8e798dd42bb3b6800fce5ce4cc861c69 to your computer and use it in GitHub Desktop.
sql postgres
-- find in JSON column array
select d -> 'data' ->> 'type' as type, *
from events e, jsonb_array_elements((e.ev_object -> 'data')::jsonb) as d
where d -> 'data' -> 'profile' ->> 'surname' = 'BRANCATI'
-- check if a value in JSON solumn exists
select *
from events e, jsonb_array_elements((e.ev_object -> 'data')::jsonb) as d
where (d -> 'data' ->> 'sysRefs') is null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment