Table structure
------------
Transaction
------------
id INT PrimaryKey
user_id INT ForeignKey
amount INT
------------
User
------------
id INT PrimaryKey
number INT
Transaction table contains multiple rows for each user, number of rows is stored in User.number (which is not same for every user)
Due to some bug in the program some extra rows has been created in Transaction table without increment User.number
Now I have to remove those extra rows from Transaction table.
As far as I know, to remove last 10 rows in Transaction table, I can run
DELETE * from Transaction ORDER BY id DESC LIMIT 10;
Is there any way to delete variable number of rows for different users in single SQL query?