mysql 子查询限制替代方案

标签 mysql subquery limit

我想选择与我最近 200 条记录不同的记录。所以我为此编写了查询

select
   distinct(server_ip)
FROM 
    resource_monitor  where server_ip IN
    (SELECT server_ip FROM resource_monitor ORDER BY id DESC LIMIT 0, 200
    )

但这显示错误

this version of mysql doesn't yet support 'limit & in/all/any/some subquery'

这个查询的替代方案是什么?

最佳答案

select distinct t1.server_ip
from (select server_ip from resource_monitor ORDER BY id DESC LIMIT 200) as t1;

关于mysql 子查询限制替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45750245/

相关文章:

php - 在 php 中发布数据失败

mysql - 无法在 Cloud shell 上连接到本地 mysql

postgresql - 返回具有最新时间戳的唯一分组行

具有未知列名的 MySQL SELECT

mysql - SQL/MySQL 递归地从同一个表中提取

mysql - 优化包含联接和子查询的查询

limit - Apple 的推送通知服务是否有流量限制?

Mysql LIMIT 使用 MATCH AGAINST

php - "LIMIT"使用列作为分隔符

php - 计算所有唯一记录