There are two tables, with a many-to-many relationship.
- The first table is Products,
- The second table is Ingredients.
- The third table is ProductsIngredients
Products (ID, Name)
Ingredients (ID, Name)
ProductsIngredients (ID, ProductID, IngredientID)
Accordingly: products can have many ingredients, and ingredients can have many products in which they are included.
It is required to obtain from the database only those products that contain, for example, both milk, millet, and sugar (and the order of indication may be chaotic). I don’t understand how to do this on the DB side, but dragging huge tables into RAM and processing on the client side is not an option, as it seems to me.
I ask for help, thanks in advance)