我要查询显示出50-100条记录怎么办,在线等。select t.en_id id,t.en_name name,d.item_name grade,t.img img,t.intraduce intr,t.address geograp from t_tour_enterprise t,t_tour_hotel h,t_tour_base_dataitem d where t.en_type=2 and h.en_id=t.en_id and d.item_id=h.hotel_level and rownum<50 order by t.en_id desc

解决方案 »

  1.   

    select   t.en_id   id,t.en_name   name,d.item_name   grade,t.img   img,t.intraduce   intr,t.address   geograp   from (select  rownum no, t.en_id   id,t.en_name   name,d.item_name   grade,t.img   img,t.intraduce   intr,t.address   geograp   from   t_tour_enterprise   t,t_tour_hotel   h,t_tour_base_dataitem   d  where rownum<=100) where no>=50
    用这个试下了
      

  2.   

    帮你顶下...
    -------------------------------------------------------------
    我的Java群:37204596
    我的SQL   Server群:13433748
    我的Oracle群:237204725  
      

  3.   

    除了1楼的方法外,还可以用 minus
      

  4.   

    select   t.en_id   id,t.en_name   name,d.item_name   grade,t.img   img,t.intraduce   intr,t.address   geograp   from   t_tour_enterprise   t,t_tour_hotel   h,t_tour_base_dataitem   d   where   t.en_type=2   and   h.en_id=t.en_id   and   d.item_id=h.hotel_level   and   rownum <=100 order   by   t.en_id   desc 
    minus (select   t.en_id   id,t.en_name   name,d.item_name   grade,t.img   img,t.intraduce   intr,t.address   geograp   from   t_tour_enterprise   t,t_tour_hotel   h,t_tour_base_dataitem   d   where   t.en_type=2   and   h.en_id=t.en_id   and   d.item_id=h.hotel_level   and   rownum <50   order   by   t.en_id   desc)
    书上看到过这种方法,用前100条减去前50条,就是50-100条记录
      

  5.   

    上面的语句写的有点问题,现在改正如下:
    select       t.en_id       id,t.en_name       name,d.item_name       grade,t.img       img,t.intraduce       intr,t.address       geograp       from       t_tour_enterprise       t,t_tour_hotel       h,t_tour_base_dataitem       d       where       t.en_type=2       and       h.en_id=t.en_id       and       d.item_id=h.hotel_level       and       rownum   <=100
    minus  select       t.en_id       id,t.en_name       name,d.item_name       grade,t.img       img,t.intraduce       intr,t.address       geograp       from       t_tour_enterprise       t,t_tour_hotel       h,t_tour_base_dataitem       d       where       t.en_type=2       and       h.en_id=t.en_id       and       d.item_id=h.hotel_level       and       rownum   <50       order       by       t.en_id       desc 
      

  6.   

    注意order by,在使用rownum并需要排序的时候,使用
    where ... rownum<50 order by col...是错误的,这样的排序没有效果,取出的数据也不是排序后的数据
    应当这样使用:
    select * from 
    (
      select rownum rn,tb.* from (
          select * from tbname order by colname
        ) tb 
     where tb<=100
    ) tb2 where rn>50;
      

  7.   

    楼上的这种方法在oracle 做分页时经常用到.呵呵.