mysql子查询限制替代

时间:2017-08-18 06:51:24

标签: 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'

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

1 个答案:

答案 0 :(得分:1)

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