Solved

Whats the difference between an INNER JOIN and a WHERE clause

Posted on 2014-10-11
7
104 Views
Last Modified: 2014-10-17
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
Comment
Question by:upobDaPlaya
[X]
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
7 Comments
 
LVL 21

Expert Comment

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

It differs for outer join.
0
 
LVL 70

Accepted Solution

by:
É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.
0
 

Author Comment

by:upobDaPlaya
ID: 40375703
Which is more efficient...
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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
0
 
LVL 21

Assisted Solution

by:pinaldave
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.
0
 
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.
0
 

Author Closing Comment

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

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
[Unsupported] SQL Update in CRM 2011 Database 19 59
SQL / Table Lock? 7 38
I am new to using JSON in SQL Server 2 53
Select Sum query with group by 8 42
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

738 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