I am facing an issue related to group_concat because when I am using this the total record can't fetch from the table based in the transactionID Here is my stored procedure code. In this I am using a split function called strSplit.
BEGIN
DECLARE iCount int;
DECLARE i int;
DECLARE txn VARCHAR(65000);
DECLARE txId VARCHAR(17);
CREATE TEMPORARY TABLE report_transaction (client_id INT NOT NULL AUTO_INCREMENT, productName VARCHAR(200), itxnId VARCHAR(100),PRIMARY KEY(client_id));
select count(distinct(tt.TxnId)) into iCount from tbl_transaction tt;
SELECT group_concat(distinct((tt.TxnId)) separator ', ') product into txn from tbl_transaction tt;
SET i=1;
WHILE i<iCount+1 DO
select strSplit(txn, ',', i) into txId;
SELECT RTRIM(LTRIM(txId));
INSERT INTO report_transaction(productName,itxnId) select group_concat((tt.ProductName) separator ',') products,tt.TxnId from tbl_transaction tt where tt.TxnId= txId;
SET i = i + 1;
END WHILE;
SELECT * FROM report_transaction;
drop table report_transaction;
END
I want result like a table record but it shows only first record and then other fields are null.