I have a query where I have to join one table to another using an OR. For example

select bar.name,
from foo
inner join bar on (foo.id1 = bar.id or foo.id2 = bar.id)

the problem is it results in duplicate rows because it is matching twice, cases when foo.id1 matches and again for the same foo.pkid when foo.id2 matches.

what I really want is only to return 1 record from foo if either matches.

So far, I've only found distinct to work but would prefer to avoid. I looked at a subquery using EXISTS but I also need columns to be output from bar which makes that difficult.

any suggestions?