Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> getting a value from a second table if the first table has not matching records
I have two tables that both contain names. There is no common index
between the two tables (they are independent of each other). Both
tables have 'name' fields, for example table TA has a column called
a_name and table TB has a column called b_name.
What I'm trying to do is to search table A for a name matching a specific value, if that does NOT match any records in table A, I want to see if there are any records in table B that match. Whichever matches, I would like the name and some other associated columns returned with a common name, e.g. final_name.
I've tried experementing with with a select case but without luck
I've tried sql like:
Select case when a.a_name is not null then a.a_name
else b.b_name ' I've also tried a selectin here as well as a when clause
Any ideas?
TIA ---Jay Received on Wed Jun 07 2006 - 06:19:22 CDT
![]() |
![]() |