I'm trying to get current stock from purchase and sale table but getting only one result.
Here is the query I wrote.
SELECT `I`.`id`, `I`.`modal`, `I`.`brand`,
IFNULL(SUM(P.qty), 0) as p_qty,
IFNULL(SUM(S.qty), 0) as s_qty,
SUM(P.qty)-SUM(S.qty) as t_qty
FROM `items` `I`
LEFT JOIN `purchase_details` `P` ON `P`.`item_id` = `I`.`id`
LEFT JOIN `sale_details` `S` ON `S`.`item_id` = `I`.`id`
WHERE `I`.`id`
IN("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70")
GROUP BY `P`.`item_id`
Expected result : All the items should come with or without zero according to stock.