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

Home -> Community -> Usenet -> c.d.o.tools -> Re: help with a simple query

Re: help with a simple query

From: Michel Cadot <micadot_at_netcourrier.com>
Date: Tue, 19 Dec 2000 09:19:08 +0100
Message-ID: <91n5mn$fhb$1@s1.read.news.oleane.net>

May be something like:

select * from a
where a.col1 = val1

   or ( a.col1 is null

      and exists (select 1 from b
                  where b.col2 = a.col2
                    and b.col1 = val1) );

or

select * from a where a.col1 = val1
union all
select a.* from a, b

where a.col1 is null
  and b.col2 = a.col2
  and b.col1 = val1;

--
Have a nice day
Michel


<javadrink_at_my-deja.com> a écrit dans le message : 91m0jq$dl2$1_at_nnrp1.deja.com...

> I need to do a following query (using table a, b):
>
>
> select *
> from a
> where a.col1=val1 or if a.col1=null then b.col1=val1
> wherea.col2 = b.col2
>
> how to express the if part using SQL? thanks a lot!
>
> (basically what I want to do is: selection based tableA column1, but if
> tableA column1 is null, join tableA with tableB using column2 and make
> sure tableB column 1 equal to the input value)
>
> Thanks!
>
>
> Sent via Deja.com
> http://www.deja.com/
Received on Tue Dec 19 2000 - 02:19:08 CST

Original text of this message

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