INNER JOIN 操作符 INNER JOIN 关键字在表中存在至少一个匹配时返回行。 SQL INNER JOIN 语法 SELECT column_name(s)FROM table1INNER JOIN table2ON table1.column_name=table2.column_name
INNER JOIN 操作符
INNER JOIN 关键字在表中存在至少一个匹配时返回行。
SQL INNER JOIN 语法
1 2 3 4 | SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;
|
登入後複製
或:
1 2 3 4 | SELECT column_name(s)
FROM table1
JOIN table2
ON table1.column_name=table2.column_name;
|
登入後複製
注释:INNER JOIN 与 JOIN 是相同的 (交集)。
Demo
1 2 3 4 5 | SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
INNER JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;
|
登入後複製
Mysql
也可以用上面的写法,等同下面
1 2 3 4 | SELECT Customers.CustomerName, Orders.OrderID
FROM Customers , Orders
WHERE Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;
|
登入後複製
更多相关教程请访问 MySQL视频教程