Search code examples
oracle-databaseinner-joinsql-delete

ORACLE SQL deleting the results of a query with a join


I have this select that uses a inner join operating properly and get the expected resultsand exported these results as insert statements. I have followed several examples found here but can't seem to get the statement formed properly.

select a.*  from app_access A inner join  PERSL B on A.empid = B.EMPID and B.CAD_CMD_MASK=7864320;
  

I would like to delete the results of this query. This is where I am right now. I cannot seem to get the statement properly formed after following several examples found here.

delete a.* from app_access where app_access A inner join  PERSL B on A.empid = B.EMPID and B.CAD_CMD_MASK=7864320;

A little background - this is in a DEV database and I have written the results of the select as insert statements. I would like to remove these records in PRODUCTION and use the insert to put in the updated records from DEV.


Solution

  • Using:

    delete app_access 
    where empid IN (SELECT B.EMPID FROM PERSL B WHERE B.CAD_CMD_MASK=7864320)