Re: Recursion with database tables
| From: | David Otton | Date: | Wed, 19 Feb 2003 13:19:17 +0000 |
| Subject: | Re: Recursion with database tables | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136169@lists.php.net to get a copy of this message | ||
On Wed, 19 Feb 2003 13:56:49 +0000, you wrote:
>One questions though - if I delete a topic, I need to delete all of its
>child messages and all of the child comments from each message. What is
>the best technique to do this? This has been driving me up the wall as
>it seems to involve some kind of looping and recursion.
make sure /all/ your comments have the correct topicid set. Then simply
"DELETE FROM comment WHERE topicid = x"
Otherwise, yes, in MySQL you have to recurse down the tree deleting
comments.