Whats the difference between an INNER JOIN and a WHERE clause

Posted on 2014-10-11
Last Modified: 2014-10-17
If I have
table Sales A
INNER JOIN table Salespeople B
A.SalesID = B.SalesID

Then what are the pro/cons of doing the below instead
table Sales A, table SalespeopleB
A.SalesID = B.SalesID
Question by:upobDaPlaya
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
LVL 21

Expert Comment

ID: 40375539
For inner join there is no difference if you put condition in where or join statement.

It differs for outer join.
LVL 70

Accepted Solution

Éric Moreau earned 250 total points
ID: 40375638
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.

Author Comment

ID: 40375703
Which is more efficient...
 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

LVL 70

Expert Comment

by:Éric Moreau
ID: 40375748
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
LVL 21

Assisted Solution

pinaldave earned 250 total points
ID: 40375828
Both will give you the same performance in the case of SQL Server when you use INNER JOIN.
LVL 70

Expert Comment

by:Éric Moreau
ID: 40375836
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.

Author Closing Comment

ID: 40387969
Thanks was always wondering on the above so thanks for answering

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question