mySQL subquery limit(mySQL 子查询限制)
问题描述
这可能是一个简单的...我怎样才能通过这个查询实现我想要的:
从没有 id 的帖子中删除(SELECT id FROM posts order by timestamp desc limit 0, 15)
所以,简而言之,我想删除所有不在最新 15 条上的帖子.
当我尝试那个查询时,我明白了
<块引用>MySQL 尚不支持 'LIMIT &IN/ALL/ANY/SOME 子查询
编辑
mySQL Server 版本:5.5.8mySQL 客户端版本:mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $
<块引用>
错误:#1235 - 此版本的 MySQL 尚不支持 'LIMIT &IN/ALL/ANY/SOME 子查询'
试试这个:
删除发件人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);
这篇关于mySQL 子查询限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mySQL 子查询限制


基础教程推荐
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01