How to perform this select?

Posted by m.edmondson on Stack Overflow See other posts from Stack Overflow or by m.edmondson
Published on 2010-12-24T09:48:57Z Indexed on 2010/12/24 9:54 UTC
Read the original article Hit count: 278

Filed under:
|
|

Say I have the simple table below:

KeyWordID   KeyWord
----------- ----------
1           Blue
3           Yellow
1           Yellow

How would I select the KeyWordID that selects the KeyWordIDs that where both KeyWord is Blue and Yellow.

E.g. it should only return 1, as this is the only KeyWordID that has both Keywords Blue and Yellow

I initially thought GROUPBY - but its not quite working as expected.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server