Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.98 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Select id where all user id match
  2. + - - - - - - - - - - - + - - - - - +
  3. ¦ fk_conversation       ¦   fk_user ¦
  4. + - - - - - - - - - - - + - - - - - +
  5. ¦ 1                     ¦     2     ¦
  6. + - - - - - - - - - - - + - - - - - +
  7. ¦ 1                     ¦     3     ¦
  8. + - - - - - - - - - - - + - - - - - +
  9. ¦ 1                     ¦     4     ¦
  10. + - - - - - - - - - - - + - - - - - +
  11. ¦ 2                     ¦     2     ¦
  12. + - - - - - - - - - - - + - - - - - +
  13. ¦ 2                     ¦     4     ¦
  14. + - - - - - - - - - - - + - - - - - +
  15.        
  16. select fk_conversation
  17. from my_table
  18. where fk_user in ( ARRAY VALUES )
  19. and fk_conversation in (
  20.     select fk_conversation
  21.     from my_table
  22.     group by fk_conversation having count(distinct fk_user) = ARRAY SIZE
  23. )
  24. group by fk_conversation
  25. having count(distinct fk_user) = ARRAY SIZE;
  26.        
  27. select fk_conversation
  28. from table
  29. where fk_user in ( comma separated array_values )
  30. group by fk_conversation
  31. having count(fk_conversation) = array_size