INNER JOIN Returns Too Many Results

Posted by Alon on Stack Overflow See other posts from Stack Overflow or by Alon
Published on 2010-03-27T22:16:11Z Indexed on 2010/03/27 22:23 UTC
Read the original article Hit count: 308

Filed under:
|
|

I have the following SQL:

SELECT *
FROM [Database].dbo.[TagsPerItem] 
INNER JOIN [Database].dbo.[Tag] ON [Tag].Id = [TagsPerItem].TagId 
WHERE [Tag].Name IN ('home', 'car') 

and it returns:

Id TagId ItemId ItemTable Id Name SiteId
1  1      1      Content  1  home  1
2  1      2      Content  1  home  1
3  1      3      Content  1  home  1
4  2      4      Content  2  car  1
5  2      5      Content  2  car  1
6  2      12     Content  2  car  1

instead of just two records, which these names are "home" and "car". How can I fix it?

Thanks.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server