[SQL] LEFT Outer Join, RIGHT Outer Join, FULL Outer Join
일반적으로는 Inner Join 즉 테이블의 교집합을 Join하지만 join하는 다른 테이블에 데이터가 없더라도 join을 하여 데이터를 얻어 오도록 하는 것이 outer join입니다.
Outer Join에는 다음과 같이 세 가지가 있습니다. LEFT, RIGHT, FULL Outer Join
LEFT OUTER JOIN
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID
ORDER BY Customers.CustomerName;
https://www.w3schools.com/sql/sql_join_left.asp
SQL LEFT JOIN Keyword
SQL LEFT JOIN Keyword SQL LEFT JOIN Keyword The LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side, if there is no match. LEFT JOIN Syntax SELECT
www.w3schools.com
RIGHT OUTER JOIN
SELECT Orders.OrderID, Employees.LastName, Employees.FirstName
FROM Orders
RIGHT JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID
ORDER BY Orders.OrderID;
https://www.w3schools.com/sql/sql_join_right.asp
SQL RIGHT JOIN Keyword
SQL RIGHT JOIN Keyword SQL RIGHT JOIN Keyword The RIGHT JOIN keyword returns all records from the right table (table2), and the matched records from the left table (table1). The result is NULL from the left side, when there is no match. RIGHT JOIN Syntax S
www.w3schools.com
FULL OUTER JOIN
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
FULL OUTER JOIN Orders ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;
https://www.w3schools.com/sql/sql_join_full.asp
SQL FULL OUTER JOIN Keyword
SQL FULL OUTER JOIN Keyword SQL FULL OUTER JOIN Keyword The FULL OUTER JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records. Note: FULL OUTER JOIN can potentially return very large result-sets! Tip: FULL O
www.w3schools.com