已连接到 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 
已连接为 mike
SQL> select * from mike_test0115;        ID NAME
---------- ----------------------------------------
         1 Mike
         2 Jimmy
        61 a%
         6 %
        61 %aa
         3 test6 行 已选择SQL> create table t1 (id number, type number);表被创建SQL> insert into t1 values(2,1);1 行 已插入SQL> insert into t1 values(6,0);1 行 已插入SQL> commit;提交完成SQL> select * from mike_test0115;        ID NAME
---------- ----------------------------------------
         1 Mike
         2 Jimmy
        61 a%
         6 %
        61 %aa
         3 test6 行 已选择SQL> select * from t1;        ID       TYPE
---------- ----------
         2          1
         6          0SQL> select r.id, r.name from mike_test0115 r,t1 where t1.id(+) = r.id order by t1.type nulls last;        ID NAME
---------- ----------------------------------------
         6 %
         2 Jimmy
         3 test
        61 a%
         1 Mike
        61 %aa6 行 已选择

解决方案 »

  1.   

    本例中mike_test0115是你的表1,t1是你的表2
      

  2.   

    比如 表1是
    id      value
    1        陕西
    2        北京
    3        河北表2是
    value
    山东
    河南
    北京
    河北
    四川
    需要的结果是表3
    id   values
    1    北京
    2    河北
    3  (表1没有 顺序无所谓,后面的要手工调整顺序,然后保存,供下一天排序使用)
      

  3.   

    没看懂,不过你按照思路来做,不一定等着完整的sql代码.
      

  4.   

    create table t3 as
    (
    select distinct t2.values from
    (select t1.id,t2.values from t1,t2
    where t2.values=t1.values) a,
    (select t2.values from t2
    where 1000 as id,t2.values not in(select values from t1)) b
    order by a.id
    )
    说实话,我不知道这个排序有没有效果.试看看吧
      

  5.   

    create table t3 as
    select values from
    (
    select nvl(t1.id,10000) , t2.values 
    from
    t2,t1
    where t2.values=t1.values(+)
    order by id
    )
      

  6.   

    create table t3 as
    select values from
    (
    select nvl(t1.id,10000) , t2.values 
    from
    t2,t1
    where t2.values=t1.values(+)
    )
    order by id
      

  7.   

    id      value
    1        陕西
    2        北京
    3        河北表2是
    value
    山东
    河南
    北京
    河北
    四川
    需要的结果是表3
    id   values
    1    北京
    2    河北
    3  (表1没有 顺序无所谓,后面的要手工调整顺序,然后保存,供下一天排序使用)实际上就是给表2的数据进行排序,但是顺序按照表1的
    因为表2里面没有陕西,所以 表3也没有,表2里在表1里id最小的 是北京,所以表3 北京是1

    到3的时候,其他的
    山东
    河南
    四川
    就随便排在后面
    然后前台界面还要调整顺序的,顺序排好了 使用,并且村为表1,供第二天排序使用
      

  8.   

    select rownumber rn,b.value from 表1 a,表2 b where a.value(+) = b.value order by a.id nulls last;
    没环境,你试试
      

  9.   

    select tb1.value from tb1 where exists(select 1 from tb2 where tb2.value=tb1.value)
    union all
    select value from tb2 where not exists(select 1 from tb1 where tb2.value=tb1.vlaue);
      

  10.   

    cenlmmx(学海无涯苦作舟)的方法正确
    别人的我没试  谢谢大家