title: Oracle database column ambiguously defined / invalid identifier
body: <p>I've tried to write a SQL statement to select from some tables. But when I run it, I get an error, and I don't know how to fix it.</p>
  
  <p>When I just select from <code>vertrag</code> and join <code>pgrdat</code>, <code>abrkreis</code>, <code>mandant</code> and <code>komm_dat</code>, everything works fine.</p>
  
  <p>However, when I try to add <code>literal</code> into the joins, I get the following error:</p>
  
  <blockquote>
    <p>ORA-00904: "VERTRAG"."MAN" invalid identifier<br/>
    on (left join literal on literal.lit_kzl = pgrdat.beruftit and literal.man = vertrag.man)</p>
  </blockquote>
  
  <p>or</p>
  
  <blockquote>
    <p>ORA-00918: column ambiguously defined<br/>
    on (left join Literal on Literal.LIT_KZL=pgrdat.BERUFTIT and Literal.man=man)<br/></p>
  </blockquote>
  
  <p><code>literal.man</code> and <code>vertrag.man</code> both exist.</p>
  
  <p>Here's my SQL:</p>
  
  <pre><code>SELECT man,
         ak,
         pnr,
         vertrag.vertnr,
         vertrag.eintrt2,
         vertrag.ma_ab,
         vertrag.verbegin,
         vertrag.ver_ab,
         vertrag.ver_bis,
         vertrag.verende,
         vertrag.enlogru,
         pgrdat.spr,
         pgrdat.anrede,
         pgrdat.auswnr,
         pgrdat.beruftit,
         pgrdat.daschudat,
         pgrdat.fax,
         pgrdat.gebdat,
         pgrdat.gebname,
         pgrdat.gebort,
         pgrdat.geschl,
         pgrdat.lnd,
         pgrdat.miname,
         pgrdat.namevor,
         pgrdat.namezus,
         pgrdat.naname,
         pgrdat.ort,
         pgrdat.plz,
         pgrdat.plzfach,
         pgrdat.postfach,
         pgrdat.pst_ab,
         pgrdat.pst_bis,
         pgrdat.staat,
         pgrdat.staat2,
         pgrdat.strasse,
         pgrdat.telgesch,
         pgrdat.telprivat,
         pgrdat.titel,
         pgrdat.vorname,
         pgrdat.empfaenger,
         pgrdat.taetint,
         pgrdat.zimmer,
         pgrdat.sachbegrp,
         pgrdat.logasach,
         pgrdat.stellung,
         pgrdat.logasach2,
         pgrdat.sachbegrp2,
         abrkreis.ak_bez,
         abrkreis.ak_kurz,
         abrkreis.ak_ort,
         abrkreis.ak_plz,
         abrkreis.ak_fax,
         abrkreis.ak_plzfach,
         abrkreis.ak_postfach,
         abrkreis.ak_strasse,
         abrkreis.ak_telefon,
         abrkreis.ak_text,
         mandant.man_bez,
         mandant.man_fax,
         mandant.man_firma,
         mandant.man_kurz,
         mandant.man_ort,
         mandant.man_plzfach,
         mandant.man_plzstr,
         mandant.man_postfach,
         mandant.man_st_nr,
         mandant.man_strasse,
         mandant.man_telefon,
         komm_dat.km_art,
         komm_dat.km_ab,
         komm_dat.km_bis,
         komm_dat.km_bem,
         literal.lit_txt
  FROM   vertrag
  JOIN   pgrdat
  USING  (man, ak, pnr)
  JOIN   abrkreis
  USING  (man, ak)
  JOIN   mandant
  USING  (man)
  LEFT   JOIN komm_dat
  USING  (man, ak, pnr)
  LEFT   JOIN literal
  ON     literal.lit_kzl = pgrdat.beruftit
  AND    literal.man = man
  WHERE  superman IN ('41900', '41901', '41902', '41903')
  AND    literal.lit_art = 'BERUFTIT'
  AND    ver_ab &lt;= trunc(SYSDATE)
  AND    pgrdat.pst_ab &lt;= trunc(SYSDATE)
  AND    ((ver_bis &gt;= trunc(SYSDATE) AND pgrdat.pst_bis &gt;= trunc(SYSDATE)) OR (ver_bis IS NULL AND pgrdat.pst_bis IS NULL));
  </code></pre>