On Wed, 19 Feb 2003 14:16:47 +0000, you wrote: >>Otherwise, yes, in MySQL you have to recurse down the tree deleting >>comments.
>How would I go about recursing down the tree? Has anyone done this before? I have, but it's been a while. Something like (pseudo-code) . def delete_comments(a) : for b in a : c = "SELECT commentid FROM comments WHERE parentcommentid = a" if len(c) > 0 : delete_comments(c) "DELETE FROM comments WHERE commentid IN (a)" return def main() : a = "SELECT commentid FROM comments WHERE topicid = 1234" delete_comments(a) "DELETE FROM topic WHERE topicid = 1234" where a is a list of commentids, b is a single commentid and c is a list of child commentids. This will delete the tree in a depth-first fashion. This is quite an intensive way of doing things (potentially many selects and deletes) but is just-about acceptable because you probably will delete an entire topic so infrequently. I recommend filling out the topicid on every post as the easier solution, though. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php