Assuming some sample data on your structures:
create table test_table (
stuff text,
property text,
innerProperty text
);
create table base_table (
property text,
id text,
stuff text
);
insert into test_table values
('foot1', 'foot', 'ball'),
('foot2', 'ultimate', 'frisbee'),
('foot3', 'base', 'ball'),
('foot4', 'nix', 'nein');
insert into base_table values
('foot', 'foot', 'feet'),
('flat', 'ball', 'pancake'),
('flit', 'frisbee', 'float');
I think in general using left outer joins instead of inner joins is the basis of the solution:
select t.stuff, bt.stuff, bt2.stuff
from
test_table t
left join base_table bt on bt.property = t.property
left join base_table bt2 on bt2.id = t.innerProperty
where
bt.property is not null or bt2.id is not null
Where the where clause mimics basically what you are trying to do -- you want a match from one or the other.
However, this yields these results:
foot1 feet pancake <- Bt2.stuff should be empty if BT matches?
foot2 float
foot3 pancake
My understanding is that if there is a match on bt then you don't want to even evaluate the second join -- make bt2 conditional on NO match from bt. If that is the case you can simply change the join condition on bt2 from this:
left join base_table bt2 on bt2.id = t.innerProperty
to this:
left join base_table bt2 on bt2.id = t.innerProperty and bt.property is null
Meaning, don't do the BT2 join if BT was successful.
Which you can see skips removes bt2.stuff = pancake from the query:
foot1 feet
foot2 float
foot3 pancake
Let me know if this is what you had in mind.