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
2333
May 05, 2012 03:36PM
1324
May 06, 2012 11:56AM
1273
May 12, 2012 04:23AM
1185
May 12, 2012 11:02AM
1317
May 12, 2012 12:02PM
1409
May 13, 2012 09:53AM
1181
May 13, 2012 11:38AM
Re: Path of entry in hierarchical table
1327
May 13, 2012 11:32AM
1223
May 13, 2012 02:39PM
1275
May 14, 2012 07:47PM
1189
May 15, 2012 01:19AM
1217
May 16, 2012 07:24AM
1536
May 16, 2012 08:45AM
1146
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.