I trying to fetch data form database which is have 3 column unique_id, parent_id & node_name, but this query (Given in below) is return only two rows.
Condition: every parent has two child.
DROP PROCEDURE `treeTbl`;
CREATE DEFINER=`bizsol`@`localhost` PROCEDURE `treeTbl`(IN `childId` INT(255)) DETERMINISTIC NO SQL SQL SECURITY DEFINER BEGIN
DECLARE tempId INT DEFAULT 0;
SELECT *, unique_id as id FROM t_users WHERE 1 AND parent_id = childId;
IF(tempId>0)
THEN
SET tempId = id;
CALL treeTbl(tempId);
END IF;
END
And call form here,
CALL treeTbl(3);