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
2506
May 05, 2012 03:36PM
1418
May 06, 2012 11:56AM
1367
May 12, 2012 04:23AM
1272
May 12, 2012 11:02AM
1417
May 12, 2012 12:02PM
1507
May 13, 2012 09:53AM
1267
May 13, 2012 11:38AM
Re: Path of entry in hierarchical table
1399
May 13, 2012 11:32AM
1300
May 13, 2012 02:39PM
1365
May 14, 2012 07:47PM
1278
May 15, 2012 01:19AM
1309
May 16, 2012 07:24AM
1619
May 16, 2012 08:45AM
1225
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.