nmsu-cs / project-penguin-byte-java-squad

project-penguin-byte-java-squad created by GitHub Classroom
0 stars 0 forks source link

Creating SQL query to display available recipes #15

Closed jyanez04 closed 5 months ago

jyanez04 commented 6 months ago

The product must be able to get the list of ingredients and make an SQL query to gather recipes that ONLY have this list of ingredients.

DouglasJack commented 5 months ago

Completed, this was a nightmare to fix. Solved yesterday.

CREATE VIEW totals AS( SELECT id, count(id) cnt2 FROM ingredients GROUP BY id );

CREATE VIEW numIng AS( SELECT id, count(id) as cnt1 FROM ingredients WHERE ingredient_name IN (' milk', ' vanilla', ' nuts', 'brown sugar', ' butter', ' bite size shredded rice biscuits') GROUP BY id );

SELECT * FROM totals, numIng WHERE totals.id = numIng.id AND cnt1 = cnt2