If you replace INNER JOIN
with OUTER JOIN
, there will be difference.
Otherwise, these queries:
SELECT ...
FROM A
INNER JOIN
B
ON A.PK = B.FK
WHERE A.Name = "Foo"
AND B.Title = "Bar"
SELECT ...
FROM A
INNER JOIN
B
ON A.PK = B.FK
AND B.Title = "Bar"
WHERE A.Name = "Foo"
SELECT *
FROM A, B
WHERE B.Title = "Bar"
AND A.Name = "Foo"
AND A.PK = B.FK
are identical.
Oracle
, MySQL
, PostgeSQL
and SQL Server
will treat them exactly the same, and use exactly same plan for all of them.
I'd use this one:
SELECT ...
FROM A
INNER JOIN
B
ON B.FK = A.PK
WHERE A.Name = "Foo"
AND B.Title = "Bar"
if there is a single-column key on B.FK
, and this one:
SELECT ...
FROM A
INNER JOIN
B
ON B.FK = A.PK
AND B.Title = "Bar"
WHERE A.Name = "Foo"
if there is a composite key on (B.FK, B.title)
.
The join conditions are more visual in this case.