[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 122
  • Last Modified:

Whats the difference between an INNER JOIN and a WHERE clause

If I have
From
table Sales A
INNER JOIN table Salespeople B
ON
A.SalesID = B.SalesID

Then what are the pro/cons of doing the below instead
table Sales A, table SalespeopleB
Where
A.SalesID = B.SalesID
0
upobDaPlaya
Asked:
upobDaPlaya
  • 3
  • 2
  • 2
2 Solutions
 
pinaldaveCommented:
For inner join there is no difference if you put condition in where or join statement.

It differs for outer join.
0
 
Éric MoreauSenior .Net ConsultantCommented:
a where clause is to filter out rows that you don't need.

Join is used to get data from other tables.

if you use a INNER join, that means that the link to the second must return data in order for the data of the first table to be returned.

a LEFT (or RIGHT) join does not filter out.
0
 
upobDaPlayaAuthor Commented:
Which is more efficient...
0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
Éric MoreauSenior .Net ConsultantCommented:
they are different. If you can avoid going to the second table, it will be more efficient but sometimes you don't have all the data in the first table to filter out unwanted rows
0
 
pinaldaveCommented:
Both will give you the same performance in the case of SQL Server when you use INNER JOIN.
0
 
Éric MoreauSenior .Net ConsultantCommented:
I looked back at your 2 queries. The second one is using the old syntax.

As said by pinaldave, in this very specific case, both queries will perform exactly the same. If you check the Execution plan for both queries (from SSMS), you would find that the SQL engine transforms the second query in the same format as the first one.
0
 
upobDaPlayaAuthor Commented:
Thanks was always wondering on the above so thanks for answering
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now