I have a puzzle (at least for me) that I hope, mainly because I'm not a master of the SQL universe yet. Basically, I have three tables:
Table A, Table B, and Table C.
Table C has an FK (Foriegn key) to table B, which has an FK for table A. (Each one is a lot for one)
I need to delete a record from table A and, of course, all its corresponding records from tables B and C. In the past, I used the cursor to do this, selecting all the records in table B and navigating through each one to delete all their corresponding records in Table C. Now it works - and it works fine, but I suspect / hope that there is a better way to achieve this effect without using cursors. So my question is, how can I do this without using a cursor, or can this be done?
(Please let me know if I was not understood - I will try to resolve the issue).
source
share