更新时间:2023-02-04 21:56:33
试试这个:
删除发件人WHERE id 不在 (选择 * 从 (选择 ID发件人ORDER BY timestamp desc limit 0, 15)作为 t);
This is probably an easy one... how can I achieve what i want with this query:
delete from posts where id not in
(SELECT id FROM posts order by timestamp desc limit 0, 15)
so, to put it in a nutshell, I want to delete every post that isn't on the latest 15.
When I try that query, I get that
MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery
EDIT
mySQL Server version: 5.5.8
mySQL Client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $
Error: #1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
Try this:
DELETE
FROM posts
WHERE id not in (
SELECT * FROM (
SELECT id
FROM posts
ORDER BY timestamp desc limit 0, 15
)
as t);