Results 1 to 1 of 1
02-11-13, 15:40 #1Registered User
- Join Date
- Feb 2010
inner join with OR cause duplicates
I have a query where I have to join one table to another using an OR. For example
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.