title: Weird Oracle SQL "Invalid Identifier" error
body: <p>Can anyone help me figure out why I get an error on <code>cms.CRIME_ID</code>:</p>
  
  <blockquote>
    <p>invalid identifier  </p>
  </blockquote>
  
  <pre><code>select c.criminal_id, c.first, c.last, cms.CRIME_ID, cc.crime_code, cc.fine_amount
  from criminals c join crimes cms on c.criminal_id = cms.criminal_id
  join crime_charges cc using (crime_id)
  order by c.first, c.last;
  </code></pre>
  
  <p>I know for an absolute fact that column exists and I can reference every other column in that table except for that. </p>
  
  <p>The only thing different about that column is that it is the primary key for that table.</p>
  
  <p>EDIT: Here is the error in full and the table creation script.</p>
  
  <pre><code>Error starting at line 1 in command:
  select c.criminal_id, c.first, c.last, cms.CRIME_ID, cc.crime_code, cc.fine_amount
  from criminals c join crimes cms on c.criminal_id = cms.criminal_id
  join crime_charges cc using (crime_id)
  order by c.first, c.last
  Error at Command Line:1 Column:39
  Error report:
  SQL Error: ORA-00904: "CMS"."CRIME_ID": invalid identifier
  00904. 00000 -  "%s: invalid identifier"
  *Cause:    
  *Action:
  </code></pre>
  
  <hr>
  
  <pre><code> CREATE TABLE crimes
        (crime_id NUMBER(9),
         criminal_id NUMBER(6),
         classification CHAR(1),
         date_charged DATE,
         status CHAR(2),
         hearing_date DATE,
         appeal_cut_date DATE);
  
  ALTER TABLE crimes
    MODIFY (classification DEFAULT 'U');
  ALTER TABLE crimes
    ADD (date_recorded DATE DEFAULT SYSDATE);
  ALTER TABLE crimes
    MODIFY (criminal_id NOT NULL);
  ALTER TABLE crimes
    ADD CONSTRAINT crimes_id_pk PRIMARY KEY (crime_id);
  ALTER TABLE crimes
    ADD CONSTRAINT crimes_class_ck CHECK (classification IN('F','M','O','U'));
  ALTER TABLE crimes
    ADD CONSTRAINT crimes_status_ck CHECK (status IN('CL','CA','IA'));
  ALTER TABLE crimes
    ADD CONSTRAINT crimes_criminalid_fk FOREIGN KEY (criminal_id)
               REFERENCES criminals(criminal_id);
  ALTER TABLE crimes
    MODIFY (criminal_id NOT NULL);
  </code></pre>
  
  <hr>
  
  <p>EDIT2: Also, I should probably mention that when not using joins and just regular select statements I can access the column just fine, as in the following code example:</p>
  
  <pre><code>select c.criminal_id, c.first, c.last, cms.crime_id, cc.crime_code, cc.fine_amount
  from criminals c, crime_charges cc, crimes cms
  where c.criminal_id = cms.criminal_id
  and cms.crime_id = cc.crime_id
  order by c.first, c.last;
  </code></pre>