Error Code: 1054. Unknown column 'diagnoses.PATIENT_IDENTIFIER' in 'on clause' when trying to JOIN two tables

84 Views Asked by At

I know it is a redundant question but I nearly spent a day to figure out why I am getting this error. Tried a lot of changes to the query below but I still get the same error! Any guidance is appreciated.

The column name in the error above "PATIENT_IDENTIFIER" exists in the Diagnoses table. I don't know if there any technical issue going on. I Used the table wizard option to import the tables in this JOIN. restarted workbench made sure the column names did not have parenthesis or spaces etc. Reuploaded the tables and so on.

USE new_pennomics ;
CREATE OR REPLACE VIEW new_patient_table AS
        SELECT 
            demographics.PatientID AS dem_patient, 
            demographics.Age_in_Years_DOB, 
            demographics.Race, 
            diagnoses.PATIENT_IDENTIFIER AS dx_patient,
            diagnoses.DIAGNOSIS_CODE, 
            diagnoses.DIAGNOSIS_DESC
        FROM demographics
        INNER JOIN diagnoses ON (demographics.PatientID = diagnoses.PATIENT_IDENTIFIER) ; 
SELECT * FROM new_pennomics.new_patient_table ;
0

There are 0 best solutions below