
January 14th, 2013, 05:21 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 26
Time spent in forums: 4 h 10 m 3 sec
Reputation Power: 0
|
|
|
Deleting rows from table, using parent-child relationship
Hi there,
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.
|