Re: Path of entry in hierarchical table
Something like...
DELIMITER //
CREATE STORED FUNCTION GetPath(_id INT UNSIGNED)
DETERMINISTIC
BEGIN
SET @id := _id, @path := '/';
WHILE (@id != 0)
SELECT @id := ParentID, @path := CONCAT('/', Name, @path) FROM tbl WHERE ID = @id;
RETURN @path;
END;
//
DELIMITER ;
Subject
Views
Written By
Posted
2521
May 05, 2012 03:36PM
1428
May 06, 2012 11:56AM
1373
May 12, 2012 04:23AM
1278
May 12, 2012 11:02AM
1426
May 12, 2012 12:02PM
1512
May 13, 2012 09:53AM
1274
May 13, 2012 11:38AM
Re: Path of entry in hierarchical table
1407
May 13, 2012 11:32AM
1306
May 13, 2012 02:39PM
1370
May 14, 2012 07:47PM
1286
May 15, 2012 01:19AM
1316
May 16, 2012 07:24AM
1623
May 16, 2012 08:45AM
1231
May 15, 2012 11:27AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.