MYSQL - Deleting orphans.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
satikas
Forum Newbie
Posts: 19
Joined: Sat Mar 28, 2009 9:14 am

MYSQL - Deleting orphans.

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: MYSQL - Deleting orphans.

Post by califdon »

Post Reply