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.

foreign key constraints


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -