try:
select tab1.id,decode(tab1.name1=tab2.code,name) cname,
decode(tab1.name2=tab2.code,name) pname,memo
from tab1,tab2
where tab1.id=tab2.id
select tab1.id,decode(tab1.name1=tab2.code,name) cname,
decode(tab1.name2=tab2.code,name) pname,memo
from tab1,tab2
where tab1.id=tab2.id
select tab1.id,decode(tab1.name1,tab2.code,name) cname,
decode(tab1.name2,tab2.code,name) pname,memo
from tab1,tab2
where tab1.id=tab2.id
from tab1 a,tab2 b,tab2 c
where a.id=b.id and a.name1=b.code
and a.name2=c.code其中a.id=b.id的条件可能不需要。
(select name from tab2 where name2=code) pname,memo
from tab1