Difference between JOIN and INNER JOIN
这两个联接都将给出相同的结果:
1 | SELECT * FROM TABLE JOIN otherTable ON TABLE.ID = otherTable.FK |
VS
1 | SELECT * FROM TABLE INNER JOIN otherTable ON TABLE.ID = otherTable.FK |
在履行或其他方面的陈述有什么不同吗?
不同的SQL实现之间有区别吗?
它们在功能上是等效的,但是
不,没有区别,纯句法糖。
内部联接=联接:
INNER JOIN is the default if you don't specify the type when you use the word JOIN.
You can also use LEFT OUTER JOIN or RIGHT OUTER JOIN, in which case the word OUTER is optional,
or you can specify CROSS JOIN.
或
For an inner join, the syntax is:
SELECT ...
FROM TableA
[INNER] JOIN TableB(in other words, the"INNER" keyword is optional - results are the same
with or without it)
与
然而,由于某种原因,我总是使用
1 2 3 4 5 6 | SELECT ColA, ColB, ... FROM MyTable AS T1 JOIN MyOtherTable AS T2 ON T2.ID = T1.ID LEFT OUTER JOIN MyOptionalTable AS T3 ON T3.ID = T1.ID |
Does it differ between different SQL implementations?
是的,Microsoft Access不允许仅使用
正如其他答案已经指出的那样,在您的示例中没有区别。
文法的相关部分记录在这里
1 2 3 | <join_type> ::= [ { INNER | { { LEFT | RIGHT | FULL } [ OUTER ] } } [ <join_hint> ] ] JOIN |
显示所有选项都是可选的。这一页进一步澄清了
INNER Specifies all matching pairs of rows are returned. Discards
unmatched rows from both tables. When no join type is specified, this
is the default.
语法也表明有一次需要使用
见下面的例子
1 2 3 4 5 6 7 8 9 10 11 12 | CREATE TABLE T1(X INT); CREATE TABLE T2(Y INT); SELECT * FROM T1 LOOP JOIN T2 ON X = Y; SELECT * FROM T1 INNER LOOP JOIN T2 ON X = Y; |