Page 1 of 1

MYSQL - Deleting orphans.

Posted: Thu Nov 12, 2009 11:29 am
by satikas
Hi, ive been searching the net for ours, yet havent found a solution for myself.
"mysql delete orphans", "mysql delete child".

My rows in a table have 2 main indicators: ID and parent.
ID is a unique value and PARENT has some other entries id.

It all starts from selecting "WHERE parent=0". From there user can navigate deeper and deeper. So the new cmds would be WHERE parent=1,345,7345...
This value comes from $_GET.

Anyway,
I cant figure out, how to delete everything under the given ID (the top of the child tree).
All its childs and their childs and their childs and so on, until there are no orphans left.

A big cookie to anyone who helps.

Re: MYSQL - Deleting orphans.

Posted: Thu Nov 12, 2009 12:31 pm
by califdon