Created
June 30, 2023 20:18
-
-
Save martinusso/2dd3e200518218637735f29fc0eba76c to your computer and use it in GitHub Desktop.
postgres jsonb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- {"1": [{"id": 1,"name": "Max"},{"id": 11,"name": "Perez"}],"2": [{"id": 2,"name": "Leclerc"},{"id": 3,"name": "Sainz"}]} | |
select | |
j.* | |
from test, | |
jsonb_each(metadata) as j | |
select | |
jsonb_each(metadata) | |
from test | |
with a as ( | |
select | |
key as k, | |
jsonb_array_elements(value) as v | |
from test, | |
jsonb_each(metadata) as j | |
) | |
select * from a | |
where v->>'name' = 'Max' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment