select * from (select rownum r,s.* from Syslog s where rownum<=20where r>=10; 这个是一个的10-20条数据 
现在我要这个表SYSLOG关联另外一个表的字段 并查出来 

解决方案 »

  1.   

    我有一个表SYSYLOG 里面有一个字段是operatrid(这个字段与systemuser中的operatrid相关联) 
    还有个表systemuser   里面有一个字段也是operatrid ,和 username字段现在我要从SYSYLOG 表中找10-20的数据  找出10-20条记录中要有username这个字段 
     
      

  2.   

    select * from (select rownum r,s.* from Syslog s where exists (select 1 from systemuser      ss where ss.operatrid=s.operatrid and ss.username is not null))where r>=10 and r<=20;
      

  3.   

    语句没有错 很好 我想要username 显示出来 在哪个地方改下 请教 楼上
      

  4.   

    谢谢 各位的指点 ,昨天写的10-20也是网上看的  没有想啊  ,其实真就是个连接查询 哈
    select rownum , syslog.*, systemuser.* from syslog, systemuser where syslog.operatrid=systemuser.userid and rownum<20 and rownum>10;但是下面的这个怎么报错了?
    select rownum r , syslog.*, systemuser.* from syslog, systemuser where syslog.operatrid=systemuser.userid and r<20 and r>10;
    报错的是红色部分。
      

  5.   

    -----你的表里又没有r这个列
    select *
      from (select rownum r, syslog.*, systemuser.*
              from syslog, systemuser
             where syslog.operatrid = systemuser.userid)
     where r < 20
       and r > 10;
      

  6.   


    select * from Syslog s where rownum<=20
    minus
    select * from Syslog s where rownum<=10
      

  7.   

    总结下啦 :查询10-20条记录。主要用于分页来显示。  但是有两个表关联的话 可以通过下面实例看看
    其中
    "select * from
    ( select rownum r, SYSLOG.LOGID,SYSLOG.EVENTCONTENT,SYSLOG.EVENTDATE,SYSTEMUSER.USERNAME from SYSLOG,SYSTEMUSER where SYSLOG.OPERATRID=SYSTEMUSER.USERID and rownum<=20
    )
    where r>=11