i actually dont know how to ask this question but i’ll try my best
This is my query for recipe_ID=2040 and Order_ID=2063
SELECT Orders.Order_ID, Stock.ID, Stock.Ingredient_Name AS [Malzeme Adı], SUM(Ingredients.Recipe_Ingredient_Gr) AS [Toplam Gram], SUM(Ingredients.Recipe_Ingredient_Piece) AS [Toplam Adet], SUM(Orders.Range_Piece * Stock.Unit_Price * Ingredients.Recipe_Ingredient_Gr) AS [Toplam Fiyat (gr)], SUM(Orders.Range_Piece * Stock.Unit_Price * Ingredients.Recipe_Ingredient_Piece) AS [Toplam Fiyat (adet)] FROM Orders INNER JOIN Dates ON Orders.Order_ID = Dates.Order_ID INNER JOIN Recipes ON 2040 = Recipes.Recipes_ID INNER JOIN Ingredients ON Recipes.Recipes_ID = Ingredients.Recipe_ID INNER JOIN Stock ON Ingredients.Stock_ID = Stock.ID WHERE(Orders.Order_ID = 2063) GROUP BY Orders.Order_ID, Stock.ID, Stock.Ingredient_Name
This is the result.
Order_ID ID Malzeme Adı Toplam Gram Toplam Adet Toplam Fiyat (gr) Toplam Fiyat (adet) 2063 1102 Domates 0 150 0 0,9 2063 1103 Dere Otu 150 0 0,45 0
but in order_ID 2063 i dont have just 1 ID infact i have up to 4 recipe_ID (which can be null)
i need to improve this query so it can look these 4 recipe_ID like ID1,ID2,ID3,ID4 from the dates table if they null skip it if they not look for their recipe ıd and put that in result