Skip to content

Instantly share code, notes, and snippets.

@jezinka
Last active April 29, 2017 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jezinka/0269db5bdc85e36699b974f41f9696af to your computer and use it in GitHub Desktop.
Save jezinka/0269db5bdc85e36699b974f41f9696af to your computer and use it in GitHub Desktop.
select ingredient._id, ingredient.name,
CASE WHEN EXISTS(
SELECT 1 from ingredient as ingredient2
join meal_ingredient on ingredient2._id= meal_ingredient.ingredient_id
join meal on meal._id= meal_ingredient.meal_id
where ingredient2._id = ingredient._id and meal._id = ?
) THEN 1
ELSE 0
END as checked
from ingredient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment