I have checked several thread of stackoverflow.com against my problem. Let me describe the my problem.
I have generated a query to get available stock based on serialno
cross checking between stockin and stockout table. My query is working fine at phpMyAdmin with no problem with correct equation. But, when I am creating a php script to download as a CSV file. Stockinhand is limiting at 5849 and CSV file row is 6041.
Stockin Hand equation is as follows-
SUM(in_quantity) - SUM(out_quantity)
GROUP BY serialno.
Stockin Hand Code as follows-
SELECT
t1.inqty, IFNULL(t2.outqty, '0') outqty, (IFNULL(t1.inqty,'0') - IFNULL(t2.outqty, '0')) totalHand,
t1.serialno, t1.inserteddate
FROM
(
SELECT *, SUM(in_quantity) inqty FROM stockin GROUP BY serialno
) t1 LEFT JOIN
(
SELECT serialno, SUM(out_quantity) outqty FROM stockout GROUP BY serialno
) t2
ON t1.serialno = t2.serialno
Downloading the CSV file fine without any errors.
Please help me to find out the problem.