Guest User

Untitled

a guest
Nov 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. id filter_id
  2. 1 5
  3. 2 5
  4. 3 5
  5. 3 17
  6. 4 17
  7. 5 17
  8.  
  9. SELECT id FROM table WHERE filter = 5 AND filter = 17
  10.  
  11. SELECT id FROM table WHERE filter IN (5, 17)
  12.  
  13. SELECT id
  14. FROM table
  15. WHERE filter IN (5,17)
  16. GROUP BY id
  17. HAVING COUNT(DISTINCT filter) = 2
  18.  
  19. select id from table
  20. where filter IN (5, 17)
  21. group by id
  22. having count(*) =2
Add Comment
Please, Sign In to add comment