简体   繁体   中英

mysql subquery limit alternative

I want to select distinct from my last 200 record. So I have wrote query for this

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

But this show me error

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

what is alternative of this query?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM