开发者

Do these MySQL SELECT queries represent different inner joins? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

which query is better and efficient - mysql

What's the difference, if any, between these two (MySQL) SELECT queries?

SELECT开发者_如何转开发 name, salary
FROM employee, info
WHERE employee.id = info.id;

SELECT e.name AS name, i.salary AS salary
FROM employee AS e
INNER JOIN info AS i
ON e.id = i.id;

Both represent an (the same?) inner join on the tables employee and info.


Yes both represents INNER JOIN.

SELECT e.name AS name, i.salary AS salary
FROM employee AS e
INNER JOIN info AS i
ON e.id = i.id;

is "explicit join notation" uses the JOIN keyword to specify the table to join, and the ON keyword to specify the predicates for the join.

SELECT name, salary
FROM employee, info
WHERE employee.id = info.id;

The "implicit join notation" simply lists the tables for joining (in the FROM clause of the SELECT statement), using commas to separate them. Thus, it specifies a cross join, and the WHERE clause may apply additional filter-predicates (which function comparably to the join-predicates in the explicit notation).

Check out this example : http://en.wikipedia.org/wiki/Join_%28SQL%29#Inner_join

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜