In MySQL I have a table ('ertek') with 2 fields: 'id': int, autoincrement 'mert': int
I'd like to delete rows where the value of 'mert' is lower than in the previous row, if I order the table by id ASC.
My query:
DELETE FROM ertek as t WHERE EXISTS (SELECT * FROM ertek AS t2 WHERE t2.id=t.id-1 AND t2.mert>t.mert)
I receive this error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as t WHERE EXISTS (SELECT * FROM ertek AS t2 WHERE t2.id=(t.id)-1 AND t2.mert>t' at line 1
Please help.