This is my current setup:
I have 2 tables, RECIPE and INGREDIENTS.
RECIPE holds the ID among other data. INGREDIENTS has X rows needed for each RECIPE.
How can one match 2 recipes with at least 2 matching ingredients?
I can do it specifying which ingredient must match, but my problem is when the recipe has more than 10 ingredients and I need two recipes that uses the same 2 ingredients, not knowing which ones.
Sorry my English, is not my natural language. I’ll post more details if needed, or if I wasn’t clear enough.
Pratical example:
Recipe 1 has: fish, potatoes and salt.
Recipe 2 has: turkey and rice.
Recipe 3 has: fish, rice and salt.
Recipe 4 has: turkey, potatoes and salt.
Result based on recipe 1 should be: 4
Result based on recipe 2 should be: None
Result based on recipe 3 should be: 1
Result based on recipe 4 should be: 1
(Yep, I need to run every recipe based on a filter not explained here)
Try something like this:
This is a rough copy. If it sounds like what you’re looking for, I can make a more elaborate example (incl. SQL Fiddle).