Skip to content
Advertisement

why i got error ora-00904 invalid identifier in insert into table?

I have 2 tables MR_FILES and WEBSITE_USERS i need to insert data from first table to secode table but i got the error ora-00904 website_users.patient_no invalid identifier , but the column already exist in the both table with same datatype number(12), this is the SELECT statement :

INSERT INTO WEBSITE_USERS (NAME) 
SELECT (FIRST_NAME_A) 
FROM MR_FILES 
WHERE  WEBSITE_USERS.PATIENT_NO = MR_FILES.PATIENT_NO;

what is the error ?

Advertisement

Answer

This sounds like you want an update:

UPDATE WEBSITE_USERS
    SET NAME = (SELECT FIRST_NAME_A 
                FROM MR_FILES 
                WHERE WEBSITE_USERS.PATIENT_NO = MR_FILES.PATIENT_NO
               )
    WHERE EXISTS (SELECT 1
                  FROM MR_FILES 
                  WHERE WEBSITE_USERS.PATIENT_NO = MR_FILES.PATIENT_NO
                 );
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement