Search code examples
sqloracle-databasepostgresqlusing

traslate query "delete join" from postgres to oracle


Hallo to everyone and thanks for the attention.I have to "traslate" from postgres to oracle this "delete join query"

DELETE FROM AAA USING BBB WHERE (AAA.date = BBB.date)
 AND (AAA.idtipo = BBB.idtipo)
 AND (AAA.tariffario = BBB.tariffario)
 AND (BBB.IDOrigine = 20 )

Thanks !! Gian


Solution

  • Use exists:

    DELETE FROM AAA 
       WHERE EXISTS (SELECT 1
                     FROM BBB
                     WHERE (AAA.date = BBB.date) AND
                           (AAA.idtipo = BBB.idtipo) AND
                           (AAA.tariffario = BBB.tariffario) AND
                           (BBB.IDOrigine = 20 )
                    );
    

    This is standard SQL and should work in both Postgres and Oracle (and other databases as well).