一尘不染

mySQL子查询限制

mysql

这可能是一个简单的…如何通过此查询实现我想要的结果:

delete from posts where id not in
(SELECT id FROM posts order by timestamp desc limit 0, 15)

因此,简而言之,我想删除所有最新的15条信息。

当我尝试该查询时,我得到了

MySQL尚不支持’LIMIT&IN / ALL / ANY / SOME子查询

编辑

mySQL Server version: 5.5.8
mySQL Client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $

错误:#1235-此版本的MySQL尚不支持“ LIMIT&IN / ALL / ANY / SOME子查询”


阅读 407

收藏
2020-05-17

共1个答案

一尘不染

尝试这个:

DELETE 
FROM posts 
WHERE id not in (
      SELECT * FROM (
            SELECT id 
            FROM posts 
            ORDER BY timestamp desc limit 0, 15
      ) 
      as t);
2020-05-17