mysql 怎么查询数据库里指定5000条id所对应的数据?

现有50000条数据,有id,code,time,value字段,求指定5000条数据的value,求代码? (id另存一张表内)

select * from t1 inner join t2 on t1.id=t2.id where rownum = 5000

查询语句后面加limit 5000吧

select  `value` from table where id between '1' and '5000'

select * from table in(ids) id在另一个表可以写个子查询查出来select * from table in(select tid from t2)

通过别的表子查询in一下呗

假设一个a表存了你的50000条数据,b表里存了指定的5000个id

    1.select * from a where id in(select id from b)
        2.select a.* from a inner join b on a.id=b.id
select t.id,t.code,t.time,t.value
from (select @rownum:=@rownum+1 as rownum, n.id,n.code,n.time,n.value
from table_name n,(select @rownum := 0) r) t
where t.rownum = 5000

这里已经给你了查第5000条数据的方法,如果还要多表联合的话,自己加上应该很简单