0

If I have a join like:

select u1.*
from users u
  inner join users u2 on u.id = u2.id
where u2.location = 'blah' and u2.level > 2

versus

select u1.*
from users u
  inner join users u2 on u.id = u2.id and u2.location='blah' and u2.level > 2

Can someone explain to me the differences and nuances of each query (assuming there is some kind of a differenc)

cool breeze
  • 4,461
  • 5
  • 38
  • 67

1 Answers1

1

There shouldn't be a noticeable difference between the two queries. Nevertheless, I would recommend using the query with the where clause. Having that on a separate line makes your query easier to read, and if you needed to rewrite it, it'll be easier for you or others to find the WHERE clause and fix it.

Here is some additional reading material for you: INNER JOIN ON vs WHERE clause

PausePause
  • 746
  • 2
  • 9
  • 21