re: sql problem
Posted in 1998
mukta mohindra — — source: Informix-list mailing list archive (1991-1998)
I have the following scenario
Table1
(Name1, Name2) - Name2 can be NULL but not Name1
Table2
(Code, Name1)
(Code, Name2).......
I have to create a report associating a common code with a combination
of Name1 and
Name2. There can be many codes associated with Name1 or Name2 but only
one code given a combination of tewo names
(Code, Name1)
(Code, Name2)
This is what I came up with
select code, name1, name2
from tab1, tab2
where (tab1.name1 = tab2.name2 or tab1.name2 = tab2.name2)
and (tab2.name2 is null or
tab2.code = (select code from tab2 A2 where (tab2.name2 = A2.name1 ortab2.name2 =
A2.name2)))
Any other ideas ????
Thanks
Mukta