This is a very important SQL query, after which my entire site is founded.
and does not work.
It is difficult to explain without an example.
There are 2 tables, One is IngredientsTable and the other is ProductTable.
In IngredentsTable I have
- Bread
- Chickenbreast
- Noodles
- mayonnaise
- Cheese
- Ketchup
- Butter
And ProductsTable
- Spageti
- Chicken breast sandwich
And there is a MAPPING TABLE table that joins both tables. He has IngredientID and ProductID.
Now Comparison
Chicken Breast Sandwich - Bread
Chicken Breast Sandwich - Mayonase
Chicken Breast Sandwich - Cheese
Chicken Breast Sandwich - Ketchup
Spaghetti --- Noodles
Spaghetti --- Cheese
Spaghetti --- Catkup
,
sql-, , .
SELECT
ProductTable.id,
ProductTable.Name
FROM ProductTable
INNER JOIN MappingTable
ON ProductTable.id = MappingTable.ProductID
WHERE MappingTable.IngredientID = 5;
, 5 ,
, WHERE MappingTable.IngredientID = 5,6; 6, ,
"," .. "" .
, WHERE MappingTable.IngredientID = 5,6,7;
!!!
.
,