首页 > 代码库 > 【数据库摘要】6_Sql_Inner_Join

【数据库摘要】6_Sql_Inner_Join

INNER JOIN 操作符

INNER JOIN keyword在表中存在至少一个匹配时返回行。

SQL INNER JOIN 语法

SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;

或:

SELECT column_name(s)
FROM table1
JOIN table2
ON table1.column_name=table2.column_name;

凝视:INNER JOIN 与 JOIN 是同样的 (交集)。

Demo

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
INNER JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

Mysql

也能够用上面的写法,等同以下

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers , Orders
WHERE  Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;    

该文为部分摘要。并又一次组织,原文地址http://www.w3cschool.cc/sql/sql-tutorial.html 获取很多其它的信息



【数据库摘要】6_Sql_Inner_Join