Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Whats the difference between an INNER JOIN and a WHERE clause

Posted on 2014-10-11
7
Medium Priority
?
115 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
  • 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 1000 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
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
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 1000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

782 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