SQL RIGHT JOIN Syntax
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;
or:
SELECT column_name(s)
FROM table1
RIGHT OUTER JOIN table2
ON table1.column_name=table2.column_name;
PS! In some databases RIGHT JOIN is called RIGHT OUTER JOIN.Example : SELECT Orders.OrderID, Employees.FirstName
FROM Orders
RIGHT JOIN Employees
ON Orders.EmployeeID=Employees.EmployeeID
ORDER BY Orders.OrderID;
result :
Number of Records: 197
OrderID | FirstName |
---|---|
Adam | |
10248 | Steven |
10249 | Michael |
10250 | Margaret |
10251 | Janet |
you can see in right side have a empty value because no id employee ( right table/ table 2 ) in orders table
Tidak ada komentar:
Posting Komentar