I have this problem while trying to select and delete. Can you guys help me to get this worked ?
SELECT `danyel_site`.`server_week`.* FROM `server_week` WHERE `weekly` = 0 AND `time` NOT IN (SELECT * FROM `server_week` WHERE `weekly` = 0 ORDER BY `time` DESC LIMIT 10)
I also want to use delete
DELETE FROM `server_week` WHERE `weekly` = 0 AND `time` NOT IN (SELECT * FROM `server_week` WHERE `weekly` = 0 ORDER BY `time` DESC LIMIT 10)
you can do it with a subquery like that
DELETE FROM `server_week` WHERE `weekly` = 0 AND `time` NOT IN
(select `time` from (
SELECT `time` FROM `server_week`
WHERE `weekly` = 0
ORDER BY `time` DESC
LIMIT 10) t )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With