Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: help with a simple query
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...Received on Tue Dec 19 2000 - 02:19:08 CST
> 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/
![]() |
![]() |