January 14th, 2013, 06:21 AM
Deleting rows from table, using parent-child relationship
I have a table, tableA, that contains one column, data type integer, that has a unique index for each row, and a few other columns that aren't important. Then I also have another table, tableB, with two columns, both integer types, named parent and child, that correspond to parent-child relationships between the indexes used in tableA.
Now I need to delete some rows from tableA. If I have two rows that have the same values for all columns except for the index, and where the two indexes are in a parent-child relationship, as found in tableB, then I need to delete the row with the child index and leave the row with the parent index alone. It seems to be necessary to use JOIN for the SQL statement, but I can't figure out how to put it together to delete the children rows only.
January 14th, 2013, 07:22 AM
joined DELETE syntax is notoriously inconsistent between various database systems
you neglected to mention which one you're using