Skip to content

Instantly share code, notes, and snippets.

@dperrera
Last active April 4, 2020 20:38
Show Gist options
  • Save dperrera/eeca5173fb14e0a4df61d5760609c9b5 to your computer and use it in GitHub Desktop.
Save dperrera/eeca5173fb14e0a4df61d5760609c9b5 to your computer and use it in GitHub Desktop.
Query JSONB column in Postgres
-- Selects all from recipe table where the ingredients of a recipe
-- has a name that includes potato (case insensitive)
SELECT *
FROM recipe, jsonb_array_elements(recipe.ingredients) ingredient
WHERE ingredient->>'name' ILIKE 'PoTaTo'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment