Oracle-11g

將表中的列匹配到另一個表

  • June 4, 2015

我在 Oracle 數據庫中有 2 個表,如果我這樣做:

SELECT ID,ID_EXTERN_FOR_JOB FROM SOL_PUBLIC.SOL_SUBSOL_CHESTIONARE@RACDB
WHERE ID=1207;

我得到:

ID      ID_EXTERN_FOR_JOB
1207    -1

在另一張桌子上,如果我這樣做:

SELECT ID,ID_EXTERN_FOR_JOB FROM SOL.SOL_SUBSOL_CHESTIONARE
WHERE ID_EXTERN_FOR_JOB=1207;

我明白了

ID      ID_EXTERN_FOR_JOB
2009    1207

而且我想找出所有與FROM中的ID_EXTERN_FOR_JOBfromSOL的“規則”不匹配的行,但我不知道該怎麼做。謝謝!ID``SOL_PUBLIC

試試這個:

SELECT  PRIV.id_extern_for_job
,       PRIV.id
,       PUB.id_extern_for_job
FROM    SOL_PUBLIC.SOL_SUBSOL_CHESTIONARE@RACDB     PUB
,       SOL.SOL_SUBSOL_CHESTIONARE                  PRIV
WHERE   PRIV.id_extern_for_job = PUB.id
AND     PRIV.id <> PUB.id_extern_for_job;

引用自:https://dba.stackexchange.com/questions/103221