2015. 6. 8. 23:22

http://www.w3schools.com/sql/sql_join_inner.asp


SQL INNER JOIN Keyword

The INNER JOIN keyword selects all rows from both tables as long as there is a match between the columns in both tables.

SQL INNER JOIN Syntax

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

or:

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

PS! INNER JOIN is the same as JOIN.

SQL INNER JOIN

SQL INNER JOIN Example

The following SQL statement will return all customers with orders:

Example

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

Try it yourself »

Note: The INNER JOIN keyword selects all rows from both tables as long as there is a match between the columns. If there are rows in the "Customers" table that do not have matches in "Orders", these customers will NOT be listed.



'SQL' 카테고리의 다른 글

RIGHT JOIN  (0) 2015.06.08
LEFT JOIN  (0) 2015.06.08
Joins  (0) 2015.06.08
Aliases  (0) 2015.06.08
BETWEEN Operator  (0) 2015.06.07
Posted by Name_null