Do you use JOIN instead of WHERE?

Last updated by Bahjat Alaadel [SSW] 4 months ago.See history

It's better to join tables together using a JOIN clause instead of a WHERE clause.


Video: Use JOIN over WHERE for SQL performance | Bryden Oliver (3 min)

There are several good reasons to use JOINs rather than WHERE clauses to join tables. The first is that it keeps the joining of tables separate from the filtering. So it means when you see a WHERE clause you know it is being used to further filter data.

The second reason is that modern SQL optimisation engines optimise JOINs better than WHERE clauses. So your query will generally run faster with a JOIN.

Finally it's easier to express the various types of joins better with a JOIN as you can state INNER, OUTER and so on depending on how you'd like to join. This achieves the equivalent of intersections, unions and so on very clearly.

We open source.Loving SSW Rules? Star us on GitHub. Star
Stand by... we're migrating this site to TinaCMS