Linked Questions
93 questions linked to/from SQL JOIN: what is the difference between WHERE clause and ON clause?
29 votes
5 answers
77k views
Why and when a LEFT JOIN with condition in WHERE clause is not equivalent to the same LEFT JOIN in ON? [duplicate]
I'm experiencing a very confusing situation that makes me question all my understanding of joins in SQL Server. SELECT t1.f2 FROM t1 LEFT JOIN t2 ON t1.f1 = t2.f1 AND cond2 AND t2.f3 > ...
20 votes
1 answer
80k views
INNER JOIN Where Clause [duplicate]
Is there a difference between doing something like SELECT * FROM table1 INNER JOIN table2 ON table2.ObjectId = table1.table2ObjectId WHERE table2.Value = 'Foo' vs SELECT * FROM table1 INNER JOIN ...
2 votes
2 answers
839 views
Is placing the filter condition inside the join on statement equivalent? [duplicate]
I always assumed that a statement of the following form SELECT * FROM A LEFT JOIN B ON (A.column1 = B.column2 AND B.column2 = 12321) is always equivalent to SELECT * FROM A LEFT JOIN B ON (A....
2 votes
3 answers
192 views
Performance difference of constraint placement in SQL join-on [duplicate]
Is there any difference in prepared query structure and thence performance, between select * from employee e join division d on e.eid = d.eid and e.div = d.div and e.level > 5 and ...
0 votes
2 answers
1k views
SQL 'WHERE' versus 'ON' (inner join) [duplicate]
When doing an SQL query, is there any significant (or any at all) difference in performance between 'WHERE' and 'ON'? I know there is a significant difference in the resulting set between the two ...
0 votes
3 answers
452 views
SQL Difference Between WHERE and ON for Joins [duplicate]
When using JOINS we have the choice of using either the WHERE clause and the OR clause. Question: is there a performance difference between these two? Should one be used over the other? What is the ...
-1 votes
2 answers
721 views
SQL LEFT JOIN: difference between WHERE and condition inside AND [duplicate]
What's the difference between select t.*, a.age from t left join a on t.ID = a.ID and a.column > 10 and select t.*, a.age from t left join a on t.ID = a.ID where a.column > 10 ? Specifically, ...
0 votes
2 answers
130 views
How below two update statements are different in SQL? [duplicate]
I have two update statements. Both of them gives the same output. How they are different and which is better to use? Statement 1: UPDATE li SET li.Description = im.Description FROM ...
0 votes
4 answers
258 views
SQL WHERE or ON for join statement [duplicate]
Way1: Select * from tableA inner join tableB on tableA.aid = tableB.aid where a.condA = xx AND a.condB = xx AND a.condC = xx Way2: Select * from tableA inner join tableB on tableA.aid = tableB.aid ...
0 votes
2 answers
124 views
difference between table joining ways [duplicate]
Possible Duplicate: SQL join: where clause vs. on clause What are the difference between of following table joining ways and which one is more appreciate for query optimization. SELECT SP.*, S....
1 vote
1 answer
116 views
Is an "on" criteria quicker than a "where"? [duplicate]
Let us suppose we have a join between t1 and t2, like this: select c1, ..., cn from t1 join t2 on t1.fk = t2.k join t3 on t2.fk = t3.k where (some condition independent from t3) where (some condition ...
-4 votes
1 answer
111 views
What is the difference between the results of the following two SQL queries? [duplicate]
SELECT r.region_name as Region, COUNT(o.*) AS CanCount FROM region AS r INNER JOIN orders AS o ON o.region_id = r.region_id WHERE r.region_id = 1 SELECT [Region] = r.region_name , [...
1 vote
0 answers
38 views
Performance : Between in FROM or in WHERE? [duplicate]
I ask myself what is the more performance method when you join table and use JOIN in clause FROM and when you need to use BETWEEN : Use Between in the FROM or Use between in the WHERE Exemple : ...
0 votes
0 answers
28 views
SQL Server - performance for filtering using LEFT JOIN ON condition versus WHERE condition [duplicate]
I have a query that was performing slowly that looked something like this: DECLARE @TeamId INT = 123 ... SELECT ... FROM Player p LEFT JOIN PlayerTeam pt ON p.PlayerId = pt.PlayerId ... WHERE pt....
0 votes
0 answers
15 views
Why does a join with 'and' some clause differ from a join followed by 'where' that same clause [duplicate]
I have two tables A id, b_id and B id, arbitrary_binary_value arbitrary_binary_value is really a field that is 1 or 0, each otherwise unique row is duplicated with a 1 and a 0, this is just some db I ...