Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Join (SQL)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Right outer join=== A '''right outer join''' (or '''right join''') closely resembles a left outer join, except with the treatment of the tables reversed. Every row from the "right" table (B) will appear in the joined table at least once. If no matching row from the "left" table (A) exists, NULL will appear in columns from A for those rows that have no match in B. A right outer join returns all the values from the right table and matched values from the left table (NULL in the case of no matching join predicate). For example, this allows us to find each employee and his or her department, but still show departments that have no employees. Below is an example of a right outer join (the '''<code>OUTER</code>''' keyword is optional), with the additional result row italicized: <syntaxhighlight lang=sql> SELECT * FROM employee RIGHT OUTER JOIN department ON employee.DepartmentID = department.DepartmentID; </syntaxhighlight> {| class="wikitable" style="text-align:center" ! Employee.LastName !! Employee.DepartmentID !! Department.DepartmentName !! Department.DepartmentID |- | Smith || 34 || Clerical || 34 |- | Jones || 33 || Engineering || 33 |- | Robinson || 34 || Clerical || 34 |- | Heisenberg || 33 || Engineering || 33 |- | Rafferty || 31 || Sales || 31 |- | {{null result}} || {{null result}} || ''Marketing'' || ''35'' |} Right and left outer joins are functionally equivalent. Neither provides any functionality that the other does not, so right and left outer joins may replace each other as long as the table order is switched. [[File:SQL Join - 05b A Full Join B.svg|alt=A Venn diagram showing the right circle, left circle, and overlapping portion filled.|thumb|A Venn diagram representing the full join SQL statement between tables A and B.]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)