Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 4th, 2012  |  syntax: None  |  size: 0.57 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Mysql performance
  2. DELETE FROM table1 WHERE id IN (SELECT id FROM table2 WHERE status = 1)
  3.        
  4. SELECT id FROM table1 WHERE delete_condition
  5.        
  6. for each delete_id
  7.     DELETE FROM table1 WHERE table1.id = delete_id
  8.     DELETE FROM table2 WHERE table2.id = delete_id
  9.     DELETE FROM table3 WHERE table3.id = delete_id
  10. loop
  11.        
  12. DELETE FROM table2 WHERE table1.id IN (SELECT id FROM table1 WHERE delete_condition)
  13. DELETE FROM table3 WHERE table1.id IN (SELECT id FROM table1 WHERE delete_condition)
  14. DELETE FROM table1 WHERE table1.id IN (SELECT id FROM table1 WHERE delete_condition)