如何解决“列定义不明确”的问题

时间:2019-04-05 07:16:55

标签: sql oracle join

有语法错误吗?我需要加入这些列并将其插入表中。 帮帮我

SELECT DISTINCT dept_in_pk.nextval,
               REFERENCE_RP_CURRENT.TADIG,
               REFERENCE_RP_CURRENT.COUNTRY,
               REFERENCE_RP_CURRENT.OPERATOR,
               REFERENCE_RP_CURRENT.GSM,
               REFERENCE_RP_CURRENT.GPRS,
               REFERENCE_RP_CURRENT.CAMEL,
               REFERENCE_RP_CURRENT.LTE,
               TEST1.MOC_LOCAL_RECORDS
            FROM REFERENCE_RP_CURRENT, TEST1
            INNER JOIN REFERENCE_RP_CURRENT
            ON TEST1.TADIG = REFERENCE_RP_CURRENT.TADIG;

2 个答案:

答案 0 :(得分:3)

您在查询中写了两次REFERENCE_RP_CURRENT。请尝试以下方法:

SELECT DISTINCT dept_in_pk.nextval,
               REFERENCE_RP_CURRENT.TADIG,
               REFERENCE_RP_CURRENT.COUNTRY,
               REFERENCE_RP_CURRENT.OPERATOR,
               REFERENCE_RP_CURRENT.GSM,
               REFERENCE_RP_CURRENT.GPRS,
               REFERENCE_RP_CURRENT.CAMEL,
               REFERENCE_RP_CURRENT.LTE,
               TEST1.MOC_LOCAL_RECORDS
          FROM TEST1
         INNER JOIN REFERENCE_RP_CURRENT
            ON TEST1.TADIG = REFERENCE_RP_CURRENT.TADIG;

答案 1 :(得分:1)

您不应该在REFERENCE_RP_CURRENT子句中加入FROM!尝试这样的事情

SELECT DISTINCT dept_in_pk.nextval,
    REFERENCE_RP_CURRENT.TADIG,
    REFERENCE_RP_CURRENT.COUNTRY,
    REFERENCE_RP_CURRENT.OPERATOR,
    REFERENCE_RP_CURRENT.GSM,
    REFERENCE_RP_CURRENT.GPRS,
    REFERENCE_RP_CURRENT.CAMEL,
    REFERENCE_RP_CURRENT.LTE,
    TEST1.MOC_LOCAL_RECORDS
FROM TEST1
    INNER JOIN REFERENCE_RP_CURRENT ON TEST1.TADIG = REFERENCE_RP_CURRENT.TADIG;

REFERENCE_RP_CURRENT子句中再次使用该表时,在FROM子句中包含JOIN会重复该表中的引用。