select m.*,l.name,l.cid from message m,list l where m.lid=l.id and (l.cid=0 OR l.cid='1') and rownum<=10 
minus 
select m.*,l.name,l.cid from message m,list l where m.lid=l.id and (l.cid=0 OR l.cid='1') and rownum<=0 order by l.cid--查询字段中加上l.cid
不知道楼主的这个查询是干什么用的.后一句用rownum<=0 ??

解决方案 »

  1.   

    里边的order子句不起作用,因为oracle会自动按照表message中列的顺序(即你查询字段的顺序,m.*)来对两个结果集进行排序并合并
      

  2.   

    order by l.cid
    無法確定是哪個表1的cid而言的
    所以會報錯无效列名
      

  3.   

    我知道楼主的意思了这样写:
    select * from
        (
        select 
            rownum as row_num,m.*,l.name,l.cid 
        from 
            message m,list l 
        where m.lid=l.id 
            and (l.cid=0 OR l.cid='1') 
        ) a
    where a.rownum between 0 and 10
    order by a.cid
      

  4.   

    错了一点select * from
        (
        select 
            rownum as row_num,m.*,l.name,l.cid 
        from 
            message m,list l 
        where m.lid=l.id 
            and (l.cid=0 OR l.cid='1') 
        ) a
    where a.row_num between 0 and 10
    order by a.cid
      

  5.   

    我是想显示表中的前十条记录,并按l.cid排序