mysql - Efficiency when deleting rows in two tables -
i have table1(id_table1) , table2(id_table2, id_table1). i'd remove records in table2 (under given condition) remove items in table1 have no more relationships table2. efficient way in sql? i'm using mysql.
thanks in advance!
if use innodb, add foreign key constraint on delete cascade
. automatically delete rows if relationship no longer correct. way, don't have query database after deleting rows in table2 check if relation still intact.
Comments
Post a Comment