如何在oracle中组合两个表列?

时间:2013-07-22 05:10:33

标签: oracle toad

Table 1:
CURRENCY CODE   ER  GUARANTOR ID    G AMOUNT
USD        1.2986   117          750
AED        4.76976  117          5750
ZAR        11.4717  117          234
INR        70.676   117          1243
AMD        526.5823 117          500000
EUR          1  117          12435
ALL       139.63197 117         2000000
EUR          1  173         200000
EUR          1  217         20000000
INR       70.676    26           100000
AED      4.76976    43          1000000
EUR          1  53          10000
Table 2:

                     F AMOUNT
USD     1.2986  117 450
AED    4.76976  117 7900
INR     70.676  117 2237.4
ZAR    11.4717  117 140.4
AMD   526.5823  117 500000
EUR          1  117 6961
ALL  139.63197  117 2000000
EUR          1  173 20000
EUR          1  217 14000000
INR     70.676  26  300000
AED    4.76976  43  2000000
EUR          1  53  10000
Result:

CURRENCY CODE   ER  GUARANTOR ID    G AMOUNT       F AMOUNT
USD        1.2986   117          750             450
AED        4.76976  117          5750            7900
ZAR        11.4717  117          234            2237.4
INR        70.676   117          1243            140.4
AMD        526.5823 117          500000         500000
EUR          1  117          12435
ALL       139.63197 117         2000000
EUR          1  173         200000
EUR          1  217         20000000
INR       70.676    26           100000
AED      4.76976    43          1000000
EUR          1  53          10000

我想结合两个表,我需要表1中的所有列和表2中的F AMOUNT列。如何实现这一目标?

先谢谢。

1 个答案:

答案 0 :(得分:0)

使用以下查询

select t1.CURRENCY CODE 
       , t1.ER 
       , t1.GUARANTOR 
       , t1.ID 
       , t2.FAMOUNT 
from table1 t1 
    , table2 t2    
where t1.CURRENCY CODE=t2.CURRENCY CODE