delete orphaned records

Results 1 to 2 of 2

Thread: delete orphaned records

  1. #1
    Join Date
    Dec 1969

    Default delete orphaned records

    Hello,<BR><BR>this is driving me mad. I have product groups and items in a database. Each record has an id, parentid and threadid. It is possible to nest groups and items e.g. groups are electrical, video, nicam with 5 products in each category and the group "video" having two sub-groups: nicam and mono.<BR><BR>If I delete the group video, how do I disable or delete all the "children" of this group? The threadid is the id of the first group, parentID is the id of the group within which the next group/ products are nested. I&#039;ve tried a few joins, which gets me the first orphaned group but not any further, as below.<BR><BR>SELECT,,,<BR>FROM prod_cat AS P1 RIGHT JOIN prod_cat AS P2 ON =<BR>WHERE ((( Is Null) AND ((;&#062;0));<BR><BR><BR>Any suggestions or examples very welcome.<BR><BR>thanks,<BR><BR>Mark

  2. #2
    Join Date
    Dec 1969

    Default Delete - Where clause...

    Keeping it simple, using two tables...<BR><BR>Table1<BR>-----------<BR>tbl1_record_id -Primary Key<BR>record_name<BR><BR>Table2<BR>-----------<BR>tbl2_record_id -Primary Key<BR>tbl1_record_id -foreign key<BR>Record_name<BR><BR>SQL = "delete from table1 where tbl1_record_id = 1"<BR><BR>SQL = "Delete from table2 where tbl1_record_id = 1"<BR><BR>You just need to create a delete where it will delete items that reffer to that same record.<BR><BR>-- Whol

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts