Suppose there is a main table containing a primary key and there is another table which contains a foreign key to this main table. So if we delete the row of main table it w
From your question, I think it is safe to assume you have CASCADING DELETES turned on. All that is needed in that case is
DELETE FROM MainTable WHERE PrimaryKey = ???
You database engine will take care of deleting the corresponding referencing records.