i have two queries.
1st gets data from different tables in database
result for 1st query looks some thing like this. query1 can return 1 row, 2 rows or 10 rows
acount_ID | product_ID | Color | QTY | Size | Prize |
2 | 2 | blk | 1 | md | 100 |
2 | 1 | red | 2 | md | 50 |
2 | 9 | yllw | 1 | sm | 10 |
2 | 5 | wht | 5 | lg | 10 |
SELECT
DISTINCT b.[Account_ID], bi.[Product_ID],bi.[QTY], bi.[Color],
bi.[Size], p.[Price]
FROM [BAG_TB] b
LEFT JOIN [BAG_ITEM_TB] bi
on bi.[Bag_ID] = b.[Bag_ID]
LEFT JOIN [PRODUCT_TB] p
on p.[Product_ID] = bi.[Product_ID]
WHERE Account_ID = 2;
2nd query is inset query. in this query, I want to get all result from query1 and insert them in [order_Detail_TB].
INSERT INTO [ORDER_Detail_TB]
(Product_ID, QTY, Color, Size, Product_Prize, Total_Prize)
VALUES
(@Product_ID, @QTY, @Color, @Size, @Product_Prize, @Total_Prize);