Skip to content

Instantly share code, notes, and snippets.

View SnugglePilot's full-sized avatar
🏠
Working from home

Andy Moore SnugglePilot

🏠
Working from home
View GitHub Profile
@SnugglePilot
SnugglePilot / gist:1128805
Created August 5, 2011 23:58 — forked from kevinpeno/gist:1128700
SQL to get all recipes that contain all ingredients the user has
CREATE VIEW view_recipe_by_ingredient AS
SELECT R.id, R.name, RI.liquorID
FROM recipes R
JOIN recipeIngredients RI ON RI.recipeID = R.id;
CREATE VIEW view_recipes_in_cabinet AS
SELECT L.userID, RbI.name, RbI.id, COUNT( RbI.liquorID ) as LiquorCount
FROM view_recipe_by_ingredient RbI
LEFT JOIN liquorCabinet L USING (liquorID)
GROUP BY RbI.name;