16:19:33 SQL> select * from table1;COL1
----------
1
2已用时间:  00: 00: 00.15
16:19:43 SQL> select * from table2;      COL1 COL2
---------- ----------
         1 aaa
         1 aab
         1 aac
         2 bba
         2 abbb已用时间:  00: 00: 00.32
16:19:48 SQL> select col2 from (
16:19:53   2  select col1||col2 col,col2 from table2
16:19:53   3  union all
16:19:53   4  select col1,col1 col2 from table1
16:19:53   5  ) order by col;COL2
----------
1
aaa
aab
aac
2
abbb
bba已选择7行。已用时间:  00: 00: 00.47
16:19:54 SQL>

解决方案 »

  1.   

    select table1.animal,table2.type,table3.name
    from table1,table2,table3
    where table1.animal = table2.animal (+)
      and table2.animal = table3.animal(+)
      and table2.type = table3.type(+)
    group by table1.animal,table2.type,table3.name不知道这样可否 ?
      

  2.   

    SELECT T1.Animal,
           T2.Type,
           T3.Name
    FROM TABLE1 T1,
         TABLE2 T2,
         TABLE3 T3
    WHERE T1.ID = T2.ID
    AND   T2.ID = T3.ID
    GROUP BY Animal,
             Type,
             Name
      

  3.   

    to bzszp(SongZip) :
    不是很懂,能不能关联三个表?
      

  4.   

    可以。
    17:10:50 SQL> select * from table3;COL1       COL2
    ---------- ----------
    aaa        aaaaa
    aaa        aaaab
    aaa        aaaac
    aaa        aaaad
    aab        aabbb
    aab        aabbc
    aac        aaccc
    bba        bbaaa
    bbb        bbbbb已选择9行。已用时间:  00: 00: 00.47
    17:13:57 SQL> select col from (
    17:14:12   2  select a.col1||b.col2||c.col2 col,c.col2 from table1 a,table2 b,table3 c
    17:14:47   3  where a.col1=b.col1 and b.col2=c.col1
    17:14:52   4  union all
    17:14:55   5  select a.col1||b.col2 col,b.col2 from table1 a,table2 b
    17:15:16   6  where a.col1=b.col1
    17:15:19   7  union all
    17:15:21   8  select a.col1,a.col1 from table1 a
    17:15:39   9  ) t order by col;COL
    ------------------------------
    1
    1aaa
    1aaaaaaaa
    1aaaaaaab
    1aaaaaaac
    1aaaaaaad
    1aab
    1aabaabbb
    1aabaabbc
    1aac
    1aacaacccCOL
    ------------------------------
    2
    2abbb
    2bba
    2bbabbaaa已选择15行。已用时间:  00: 00: 00.46
    17:15:49 SQL> 
      

  5.   

    上面的选错了列,把排序用的列显示出来了。:)17:15:49 SQL> select col2 from (
    17:17:39   2  select a.col1||b.col2||c.col2 col,c.col2 from table1 a,table2 b,table3 c
    17:17:43   3  where a.col1=b.col1 and b.col2=c.col1
    17:17:43   4  union all
    17:17:43   5  select a.col1||b.col2 col,b.col2 from table1 a,table2 b
    17:17:43   6  where a.col1=b.col1
    17:17:43   7  union all
    17:17:43   8  select a.col1,a.col1 from table1 a
    17:17:43   9  ) t order by col;COL2
    ----------
    1
    aaa
    aaaaa
    aaaab
    aaaac
    aaaad
    aab
    aabbb
    aabbc
    aac
    aacccCOL2
    ----------
    2
    abbb
    bba
    bbaaa已选择15行。已用时间:  00: 00: 00.62
    17:17:44 SQL>
      

  6.   

    感谢:bzszp(SongZip) ,感谢各位!