Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL*Plus question

Re: SQL*Plus question

From: Peter Mubaiter <this.is.not.valid_at_spammer.hola>
Date: Mon, 31 Jan 2005 18:32:58 +0100
Message-ID: <1107192806.281a09760149e54df84927c9dcba588e@teranews>


Andy Kent schrieb:
> I've got a really simple requirement.
> Basically all I want to do is:
>
> select * from table1 where key=value;
> if found
> display it;
> else
> select * from table2 where key=value;
> display it;
> end if;

If the table structure is the same then

select *

   from table1
  where key1=value1
union
select *

   from table2
  where key2=value2 and
    and 0 = (select count(*) from table1 where key1=value1)

would do it.

HTH, Peter Received on Mon Jan 31 2005 - 11:32:58 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US