code_junkie

SQL Division using 'not exists' in mysql

Nov 12th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. select distinct b.profname from committee b
  2. where not exists (
  3. select commname from committee a
  4. where a.profname = 'piper' and not exists (
  5. select commname from committee c
  6. where c.profname=b.profname and c.commname=a.commname
  7. )
  8. );
  9.  
  10. select distinct b.profname from committee b
  11. where not exists (
  12. select commname from committee a
  13. where a.profname = 'piper' and not exists (
  14. select commname from committee c
  15. where c.profname=b.profname and c.commname=a.commname
  16. )
  17. );
  18.  
  19. select distinct b.profname from committee b
  20. where not exists (
  21. select commname from committee a
  22. where a.profname = 'piper' and not exists (
  23. select commname from committee c
  24. where c.profname=b.profname and c.commname=a.commname
  25. )
  26. );
Add Comment
Please, Sign In to add comment