Created
January 10, 2017 20:01
-
-
Save ryantuck/c1f779669425f667b1caa2acadfec838 to your computer and use it in GitHub Desktop.
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
-- find rows where a certain key exists | |
select | |
* | |
from | |
my_table | |
where | |
json_field::jsonb ? 'key_i_want' | |
; | |
-- get certain key from json field | |
select | |
json_field::jsonb -> 'key_i_want' | |
from | |
my_table | |
; | |
-- the following syntax also works for referencing particular fields | |
select | |
json_field ->> 'key_i_want' | |
from | |
my_table | |
where | |
json_field::jsonb ? 'some_qualifier' and | |
json_field ->> 'other_key' = 'blah' | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment