PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > comp.db.ms-sqlserver > difference between explicit inner join and implicit
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
difference between explicit inner join and implicit

Réponse
 
LinkBack Outils de la discussion
Vieux 31/03/2008, 19h02   #1
YZXIA
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut difference between explicit inner join and implicit

Is there any difference between explicit inner join and implicit
inner join

Example of an explicit inner join:

SELECT *
FROM employee
INNER JOIN department
ON employee.DepartmentID = department.DepartmentID

Example of an implicit inner join:

SELECT *
FROM employee, department
WHERE employee.DepartmentID = department.DepartmentID
  Réponse avec citation
Vieux 31/03/2008, 19h28   #2
christopher.secord@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

On Mar 31, 1:02 pm, YZXIA <yz...@hotmail.com> wrote:
> Is there any difference between explicit inner join and implicit
> inner join


The execution plan for both queries is the same, so that suggests to
me that they are functionally identical.
  Réponse avec citation
Vieux 31/03/2008, 19h49   #3
--CELKO--
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

>> Is there any difference between explicit [sic: infixed] inner join and implicit inner join <<

In theory, yes; in practice, no. The SQL-92 Standard says that the
infixed join notation is executed in left-to-right order in the FROM
clause. But the optimizer is free to re-arrange the query as long as
the results are the same.

This does not make a difference with INNER JOINs, but it is vital with
OUTER JOINs.

There is a good story about this proposal. We needed the OUTER JOIN
syntax; the proprietary methods in Oracle, SQL Server, Sybase,
Informix, etc. were all screwed up. But after we had defined the
OUTER JOIN, it was easy to extend the paper to INNER JOIN, UNION JOIN,
NATURAL JOIN, etc. (most of which nobody implements).

The rationale after the fact was that a product could have an option
to force an order of execution with the infixed notation. Since SQL
products now have some kind of optimizer, it is not really useful.

The real difference is in the mindset of programmers. Those that
write with infixed notation thing in terms of a linear sequence of
joins, as if they were limited to simple binary Theta operators. The
programmers that use the older notation will use BETWEEN, IN () and
other predicates that work with multiple terms.
  Réponse avec citation
Vieux 31/03/2008, 21h43   #4
Shuurai
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit


> Is there any difference between explicit inner join and implicit
> inner join


Technically no, but it's a good idea to make it a habit to use the
explicit inner join. It is considered the standard nowadays, is
easier to read and debug, and is consistent with the OUTER JOIN
syntax.

  Réponse avec citation
Vieux 01/04/2008, 04h12   #5
Ed Murphy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

--CELKO-- wrote:

> The real difference is in the mindset of programmers. Those that
> write with infixed notation thing in terms of a linear sequence of
> joins, as if they were limited to simple binary Theta operators. The
> programmers that use the older notation will use BETWEEN, IN () and
> other predicates that work with multiple terms.


Like this, you mean? And are you recommending or deprecating it?

select a.x, b.y
from table1 a
join table2 b on a.x between b.y and 500
  Réponse avec citation
Vieux 01/04/2008, 15h01   #6
--CELKO--
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

>> Like this, you mean? <<

No, try this:

SELECT ..
FROM A, B, C
WHERE A.x BETWEEN B.y AND C.z;

Versus:

SELECT ..
FROM A
INNER JOIN
B
ON A.x >= B.y
INNER JOIN
C
ON C.z <= A.x;

The "between" is lost in what typographers call the law of proximity
because things are split into binary operators. Likewise, look around
this newsgroup for

a = x1 OR a = x2 or a = x3

versus
a IN (x1, x2, x3)

The set of matches is lost in the binary operators. My favorite
example of this mindset is

x1 = 0 OR x2 = 0 OR x3 = 0
versus
0 IN (x1, x2, x3)

Because the binary mindset is a left-to-right English based ordering
that says "x is zero" and "zero is x" when coding. I used to run into
this difference with Arab and Asian students who did not have this
cultural baggage.



  Réponse avec citation
Vieux 01/04/2008, 15h07   #7
--CELKO--
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

>> Technically no, but it's a good idea to make it a habit to use the explicit inner join. It is considered the standard nowadays, <<

Not when I was on the Standards Committee; did you join later than
me?

>> is easier to read and debug, <<


NO, it isn't; have you seen any of the human factors research? The ON
clauses can be spread so far from the matching tables debugging time
increases. Multiple parameter predicates like BETWEEN and IN are
split and their higher level meaning is lost.

But it looks like ACCESS and has a nice binary operator feel that
procedural programmers like.

>> and is consistent with the OUTER JOIN syntax. <<


Yes, that is the reason it exists.

  Réponse avec citation
Vieux 02/04/2008, 00h20   #8
Hugo Kornelis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

On Tue, 1 Apr 2008 07:01:14 -0700 (PDT), --CELKO-- wrote:

>>> Like this, you mean? <<

>
>No, try this:
>
>SELECT ..
> FROM A, B, C
> WHERE A.x BETWEEN B.y AND C.z;
>
>Versus:
>
>SELECT ..
> FROM A
> INNER JOIN
> B
> ON A.x >= B.y
> INNER JOIN
> C
> ON C.z <= A.x;
>
>The "between" is lost in what typographers call the law of proximity
>because things are split into binary operators.


Hi Joe,

And both versions hide the actual relationship between B and C.

SELECT ..
FROM B
INNER JOIN C
ON C.z >= B.y
INNER JOIN A
ON A.x BETWEEN B.y AND C.z;

Now we have the "between", *and* the relationship between B and C is
shown explicitly. Looks like a winner to me!

(Though I have to admit that I'd be hardpressed to come up with an
example that makes it even vaguely believeable that a query such as this
would ever show up in the real world).

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
  Réponse avec citation
Vieux 03/04/2008, 02h57   #9
--CELKO--
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

>> Now we have the "between", *and* the relationship between B and C is shown explicitly. Looks like a winner to me! <<

No, no! What you have done is hide redundancy which would have been
clearly shown in a simple WHERE clause. I don't think I am the only
guy who puts all the WHERE clause predicates into a tool to sort them
to see exactly what predicates go to which tables.


>> (Though I have to admit that I'd be hard pressed to come up with an example that makes it even vaguely believable that a query such as this would ever show up in the real world). <<


LOL! We have seen much worse in this newsgroup!
  Réponse avec citation
Vieux 13/04/2008, 03h22   #10
Neil H
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

If anyone is willing to a novice,

is there any difference between the JOIN operator and the INNER JOIN
operator?

For example, in a sample database, I get identical results when I run

SELECT title, name
FROM books JOIN publisher
USING (pubid)

and

SELECT title, name
FROM books INNER JOIN publisher
USING (pubid)

Thanks,

Neil

*** Sent via Developersdex http://www.developersdex.com ***
  Réponse avec citation
Vieux 13/04/2008, 14h46   #11
DeanGC
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

On Apr 12, 7:22 pm, Neil H <trumbol...@yahoo.com> wrote:
> If anyone is willing to a novice,
>
> is there any difference between the JOIN operator and the INNER JOIN
> operator?
>
> For example, in a sample database, I get identical results when I run
>
> SELECT title, name
> FROM books JOIN publisher
> USING (pubid)
>
> and
>
> SELECT title, name
> FROM books INNER JOIN publisher
> USING (pubid)


No, there is no difference. They are the same. 'INNER' is optional:
the default JOIN is INNER JOIN.

Whether you write INNER or not is a matter of style.
  Réponse avec citation
Vieux 13/04/2008, 16h03   #12
Erland Sommarskog
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

Neil H (trumbology@yahoo.com) writes:
> If anyone is willing to a novice,
>
> is there any difference between the JOIN operator and the INNER JOIN
> operator?
>
> For example, in a sample database, I get identical results when I run
>
> SELECT title, name
> FROM books JOIN publisher
> USING (pubid)
>
> and
>
> SELECT title, name
> FROM books INNER JOIN publisher
> USING (pubid)


No, "JOIN" is just short for "INNER JOIN".

However, the USING syntax does not appear in MS SQL Server (which is the
topic for this newsgroup), so you seem be using a different product.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
  Réponse avec citation
Vieux 14/04/2008, 20h52   #13
--CELKO--
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit

INNER is a shorthand for INNER JOIN, and USING is a shorthand for an
equi-join. Nobody really likes USING, since adding more tables and re-
compiling can give you surprises.
  Réponse avec citation
Vieux 16/04/2008, 18h11   #14
Shuurai
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: difference between explicit inner join and implicit


> >> Technically no, but it's a good idea to make it a habit to use the explicit inner join. It is considered the standard nowadays, <<

>
> Not when I was on the Standards Committee; did you join later than
> me?


The INNER JOIN syntax is the current standard. It is considered
"standard" by those who actually work in the field. How long ago was
it that you were on the Standards Committee?

You seriously need to stop pulling this "I was on the committee" crap
in place of having a valid argument. The fact of the matter is, the
vast majority of us are using the INNER JOIN syntax. If you feel like
doing things the old way, whatever.

> >> is easier to read and debug, <<

>
> NO, it isn't; have you seen any of the human factors research?


YES, it is. That is one of the main reasons why people who actually
work in the field have so widely adopted it. But just for fun, why
don't you post a link to the research that shows that the syntax
practically *everyone* has adopted with open arms is so much worse
than the syntax we all (just as willingly) dropped.

> The ON clauses can be spread so far from the matching tables debugging time
> increases. Multiple parameter predicates like BETWEEN and IN are
> split and their higher level meaning is lost.


Debugging time is actually diminished because the join criteria is not
mixed in with the filtering criteria. If you find yourself "losing"
predicates then maybe the problem is with you and not the syntax.

> But it looks like ACCESS and has a nice binary operator feel that
> procedural programmers like.


I could care less what looks like ACCESS. I don't personally use
ACCESS; have never been a fan.

> >> and is consistent with the OUTER JOIN syntax. <<

>
> Yes, that is the reason it exists.


Whatever the reason, the fact is it is currently the accepted industry
standard. If you do not realize/understand this, that is your issue.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h24.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,21583 seconds with 22 queries