MySQL Forums
Forum List  »  InnoDB

combining deletes
Posted by: yawnmoth
Date: June 09, 2005 08:54PM

How would I go about combining the following deletes into a single
delete operation that's compatable with MySQL 4?

DELETE FROM some_random_table WHERE a=1 ORDER BY b ASC LIMIT 2
DELETE FROM some_random_table WHERE a=2 ORDER BY b ASC LIMIT 2
...
DELETE FROM some_random_table WHERE a=MAX(a) ORDER BY b ASC LIMIT 2

Also, the above DELETEs deletes two rows for each a. How could I make it so that all but two rows are deleted for each a? Although a single query would be preferable, multiple queries would be sufficient.

Options: ReplyQuote


Subject
Views
Written By
Posted
combining deletes
2612
June 09, 2005 08:54PM
1708
June 30, 2005 06:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.