I'm trying to delete the most lower 60 rows but its not working. I tried some other posts in stackoverflow but non of them worked for me.
DELETE FROM windUpdates
WHERE INDEX <= (
( SELECT MAX( INDEX ) FROM windUpdates ) - 60
)
Thanks.
you need to create temporary table for the result of your subquery,
DELETE FROM tablename
WHERE `Index` NOT IN
(
SELECT `Index`
FROM
(
SELECT `Index`
FROM tablename
ORDER BY `Index` DESC
LIMIT 60
) x
)
PS: Be sure to backup your database first.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.