这些MySQL SELECT查询代表不同的内连接吗?

时间:2011-09-26 12:37:18

标签: mysql sql

  

可能重复:
  which query is better and efficient - mysql

这两个(MySQL)SELECT查询之间有什么区别?

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;

两者都代表表employeeinfo上的(相同?)内连接。

1 个答案:

答案 0 :(得分:1)

是的,两者代表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;

"explicit join notation"使用JOIN关键字指定要连接的表,使用ON关键字指定连接的谓词。

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

"implicit join notation"只列出要加入的表(在SELECT语句的FROM子句中),使用逗号分隔它们。因此,它指定了cross join,并且WHERE子句可以应用其他过滤谓词(其功能与显式表示法中的连接谓词相当)。

查看此示例:http://en.wikipedia.org/wiki/Join_%28SQL%29#Inner_join