I know, that there is a thing in MySQL called 'on delete cascade' and that means (as far as i can understand): when you delete a certain row in a table, all records in the other tables, that have a reference on it will be deleted too. And that happens without any other queries or delete statements. So now my problem is: I have a situation, that is pretty similar to that one. There is a table (A) with a primary key column, and a certain amount of other tables (B, C, ...) have a column, which references (foreign key) to that column in table A. Now i have a row in A with the primary key 22 and i want to determine all the occurrences of 22 in the other tables. So it is possible, that 22 occurs in C and F, but not in B, D or E ...
If it's possible to delete every reference with 'on delete cascade', can i realize my problem on a similar way?
My solution so far: i look up in every table, if there is a 22 in the foreign key column, but that may take a long time, when there is a large amount of tables/rows in it. Are there any better solutions?