Created
January 7, 2010 14:15
-
-
Save remvee/271245 to your computer and use it in GitHub Desktop.
MySQL EXISTS vs IN
This file contains hidden or 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
| # MySQL basic ..IN (SELECT.. | |
| SELECT * FROM foos WHERE foo IN (SELECT foo FROM bars); | |
| # can be rewritten to the much faster: | |
| SELECT * FROM foos WHERE EXISTS (SELECT 1 FROM bars WHERE bars.foo = foos.foo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment