Trying to delete all records from table mensajes
except the last 40 I get this error:
#1235 - This version of MariaDB does not yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
The version of my MariaDB Server is:
Server version: 10.1.21-MariaDB mariadb.org binary distribution
This is my query:
DELETE *
FROM mensajes
WHERE id NOT IN (
SELECT id
FROM mensajes
ORDER BY id DESC
LIMIT 40
)
Is there a way to achieve what I need in one query?
One solution is to move the query that contains it
LIMIT
to a derived table.Example:
credits