1

I have a table that contains ID and Keywords I need to create that allow to select where 2 or more keyword are present Example: Where keyword = 779 AND keyword = 782 should result in 4347

ID      Keyword
------------------
4347    779
4347    782
8853    779
8853    780
8853    787

I am using IN clause for letting user choose OR case Where Keyword IN (X,y,Z) is there something simlar Keyword IN (X AND Y AND Z) ?

Kris1511
  • 190
  • 3
  • 14

1 Answers1

2

Assuming if ID 8975 had 7 key words 2 of which were 779 and 782 and you'd want that one as well...

SELECT ID 
FROM table
WHERE Keyword in (779,782)
GROUP BY ID
HAVING count(distinct keyword) >= 2
xQbert
  • 34,733
  • 2
  • 41
  • 62