Hi, from my experience
CREATE TABLE message ( id int(10) NOT NULL auto_increment, parent_id int(10) NOT NULL default '0', parents varchar(255) NOT NULL default '', level tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (id), KEY parent_id (parent_id), KEY parents (parents) ); field `parents` - all the 'ancestor-or-self' (using xslt terminology:) ) of the current row delimited by `,`; filed `level` - 0 for the root node, 1 for its children, 2 for children of children, etc... and you can simple get a full branch starting from id=2 with: select * from message where parents like '1,2,%' order by parents (Assume row with id=2 is a child of row with id=1) It is not a 'really good' solution, but it works good for me. Alternatively, you can use additional table CREATE TABLE message ( id int(10) NOT NULL auto_increment, parent_id int(10) NOT NULL default '0', level tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (id,parent_id) ); to maintain all the links... And much more..., or use ORACLE with its "STARTS WITH, CONNECT BY", etc :), very useful feature, not supported by mysql :) Alexander --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php