Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

Tags:

mysql

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)
like image 714
Dany Avatar asked Oct 13 '13 10:10

Dany


1 Answers

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 ) 
like image 194
echo_Me Avatar answered Nov 15 '22 05:11

echo_Me