Oracle
 sql >> Database >  >> RDS >> Oracle

Seleziona dalla tabella se il record è stato trovato in un'altra tabella

Puoi fare qualcosa del genere:

-- If value is found in table2, select from table1
select * -- <- use padding if necessary 
  from table1
 where exists (select 1
                 from table2
                where myField = value)

union all

-- If value is not found in table2, select from another_Table
select * -- <- use padding if necessary
  from another_Table
 where not exists (select 1
                     from table2
                    where myField = value)