#1235 - 此版本的MySQL尚不支持'LIMIT& IN / ALL / ANY / SOME子查询'

时间:2013-10-13 10:11:03

标签: mysql

我在尝试选择和删除时遇到此问题。你能帮我解决这个问题吗?

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)

我也想使用删除

DELETE FROM `server_week` WHERE `weekly` = 0 AND `time` NOT IN (SELECT * FROM `server_week` WHERE `weekly` = 0 ORDER BY `time` DESC LIMIT 10)

1 个答案:

答案 0 :(得分:18)

你可以用这样的子查询来做到这一点

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 )