This question already has answers here:
Inner join vs Where
(19 answers)
SQL JOIN - WHERE clause vs. ON clause
(22 answers)
INNER JOIN ON vs WHERE clause
(12 answers)
Closed 9 years ago.
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 for a LEFT or RIGHT JOIN.
What about an INNER JOIN?
Is there any drawback to using 'ON' for each of my selects rather than 'WHERE' at the end?
Performance wise, they should be the same. However, see this article for an opinion of an industry veteran regarding the readability and maintenace-friendliness.
While the old-style joins still work, you can't do an outer join anymore
Execution plans for both are identical. Many people prefer the use of ON though.
Related
This question already has answers here:
Explicit vs implicit SQL joins
(12 answers)
Closed 5 years ago.
I get the same result in both queries below and same execution plan, any difference? or it is just how I prefer to write my query?
SELECT PS.StepID,PR.ProgramID FROM ProgramSteps PS, Programs PR
WHERE PS.ProgramID = PR.ProgramID
SELECT PS.StepID,PR.ProgramID FROM ProgramSteps PS
INNER JOIN Programs PR ON PS.ProgramID = PR.ProgramID
One difference is that the first option hides the intent by expressing the join condition in the where clause.
The second option, where the join condition is written out is more clear for the user reading the query. It shows the exact intent of the query.
As far as performance or any other difference, there shouldn't be any. Both queries should return the exact same result and perform the same under most RDBMS.
And as #Tim Biegeleisen says in the comments:
the comma version is deprecated as of the ANSI-92 SQL standard
This question already has answers here:
INNER JOIN ON vs WHERE clause
(12 answers)
Closed 5 years ago.
Are the following two select SQL statements exactly equal? I usually use the join keyword, but I found that the sqlite author uses the second form in some of his document pages on sqlite.org.
The "inner join...on" form
SELECT * FROM Order INNER JOIN OrderItem ON Order.Id = OrderItem.ParentId
The "where" form
SELECT * FROM Order, OrderItem WHERE Order.Id = OrderItem.ParentId
Update 1:
I found this question might be duplicated, it seems has something to do with the SQL89 and SQL92 standards, but it doesn't answer me the second form is an "INNER JOIN", "OUTER JOIN" or anything else.
Result will be the same but there are separate purpose of each syntax.
for more details check this inner join vs where
If you talk about specifically the query you mentioned then yes both will result the same but join and where clause don't give same results. join is used for joining two tables and where clause is further used to specify the data selection from those tables.
This question already has answers here:
Explicit vs implicit SQL joins
(12 answers)
Closed 6 years ago.
I am currently learning SQL. I am trying to create Views using Oracle SQL Developer. I came across the JOIN statement but I do not understand why do we need JOIN. According to W3School, the purpose of JOIN is to join multiple rows together. I can do that without the expression JOIN (refer to the following code blocks, both of them produce the same view/table). So what is the purpose of JOIN?
With INNER JOIN:
SELECT
Acc.Cust_Id,
Cus.Address,
Acc.Avail_Balance
FROM
Account Acc
INNER JOIN
Customer Cus
ON
Acc.Cust_Id = Cus.CUST_ID
Without INNER JOIN:
SELECT
Acc.Cust_Id,
Cus.Address,
Acc.Avail_Balance
FROM
Account Acc,
Customer Cus
WHERE
Acc.Cust_Id = Cus.CUST_ID
The two queries are the same, except the 1st one ANSI-92 SQL syntax and the and other is older SQL syntax which didn't incorporate the join clause. They should produce exactly the same internal query plan, although you may like to check.
check This link
ANSI vs. non-ANSI SQL JOIN syntax
This question already has answers here:
Difference between JOIN and INNER JOIN
(6 answers)
Closed 8 years ago.
Is there any performance - difference between inner join and simple join?
i.e. does either of them have a better execution plan and/or execution time?
And will both these approaches always yield same result sets?
JOIN with no qualifier is just an abbreviation for INNER JOIN, they are exactly the same. If any database had a performance difference, I would report it as a bug.
This question already has answers here:
Difference between Oracle's plus (+) notation and ansi JOIN notation?
(8 answers)
Closed 9 years ago.
I'm going through some code and came across a view and was wondering what part of the WHERE statement was doing, it looks like so.
receipt_note.receipt_num(+) = receipt_data.receipt_num
receipt_num is a NUMBER in the table. I just don't know what the (+) would be doing here. Is it adding 1 to that number, like in coding where you would do variable++
(+) is the (old) outer join operator in Oracle. It is specifying an outer join between the receipt_num columns of the receipt_note table and the receipt_data table.
This syntax is obsolete; new queries should use OUTER JOIN instead since it is more readable.