I have two tables which I want to join together using a left outer join. However, even though my left table contains only unique values, the right table satisfies the CONDI
Sorry, but your thinking is skewed.
Think about it this way: if you only want one single row from tb2 for each row in tb1, which one should the server choose? The fact is that from the definition of a join, every row in the right-hand-side table that matches the left-hand-side row is a match and must be included.
You'll have to ensure tbl2 has distinct values for c2 before the join. Murph's suggestion might do it, provided your SQL variant supports DISTINCT [column] (not all do).
Hmm, the query is doing what its supposed to since there are duplicate records (or at least duplicate identifiers) in the right hand table.
To get the effect you want something like:
SELECT * FROM @tb1 LEFT OUTER JOIN (SELECT DISTINCT c2 FROM @tb2) t2 ON @tb1.c1 = t2.c2
If that isn't sufficient you'll need to explain the requirement in a bit more detail.
Try useing
select DISTINCT * from @tb1 left outer join @tb2 ON c1 = c2
If you want to keep just single rows on the left hand side, you'll need to decide what you want to show on the right, for each unique value on the left. If you want to show a count, for example, you could do this:
select b1.c1, x.c from @tb1 b1
left outer join
(
select c2, count(*) as c
from @tb2
group by c2
) as x
ON b1.c1 = x.c2
or if you just want one occurence of values from c2:
select b1.c1, x.c2 from @tb1 b1
left outer join
(
select c2
from @tb2
group by c2
) as x
ON b1.c1 = x.c2
select distinct * from @tb1 left outer join @tb2 ON c1 = c2