Created
June 17, 2011 03:34
-
-
Save mpurbo/1030819 to your computer and use it in GitHub Desktop.
Simple many-to-many PostgreSQL query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT pg.* | |
FROM programmers pg | |
WHERE EXISTS( | |
SELECT pp.programmer_id | |
FROM programmers_projects pp | |
WHERE | |
pp.programmer_id = pg.programmer_id AND | |
pp.project_id IN (1, 2) -- or whatever condition to filter the projects | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment