CINXE.COM

Join (SQL) - Wikipedia

<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-sticky-header-enabled vector-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Join (SQL) - Wikipedia</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-sticky-header-enabled vector-toc-available";var cookie=document.cookie.match(/(?:^|; )enwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy", "wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"86a4ff3e-fbf9-4000-b8fc-44310f9b42ab","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Join_(SQL)","wgTitle":"Join (SQL)","wgCurRevisionId":1274538111,"wgRevisionId":1274538111,"wgArticleId":665204,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Webarchive template wayback links","Articles with short description","Short description matches Wikidata","Wikipedia articles needing clarification from May 2021","Articles with specifically marked weasel-worded phrases from September 2022","Articles with example SQL code","SQL keywords"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Join_(SQL)","wgRelevantArticleId":665204,"wgIsProbablyEditable":true, "wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":"wikipedia","wgCiteReferencePreviewsActive":false,"wgFlaggedRevsParams":{"tags":{"status":{"levels":1}}},"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":0,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":40000,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q2003535","wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false, "wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false};RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.pygments":"ready","ext.cite.styles":"ready","ext.math.styles":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","jquery.makeCollapsible.styles":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready"};RLPAGEMODULES=["ext.pygments.view","ext.cite.ux-enhancements","mediawiki.page.media","ext.scribunto.logs","site","mediawiki.page.ready","jquery.makeCollapsible","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.gadget.ReferenceTooltips","ext.gadget.switcher","ext.urlShortener.toolbar","ext.centralauth.centralautologin", "mmv.bootstrap","ext.popups","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.interface","ext.cx.eventlogging.campaigns","ext.cx.uls.quick.actions","wikibase.client.vector-2022","ext.checkUser.clientHints","ext.growthExperiments.SuggestedEditSession"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=ext.cite.styles%7Cext.math.styles%7Cext.pygments%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cjquery.makeCollapsible.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&amp;only=styles&amp;skin=vector-2022"> <script async="" src="/w/load.php?lang=en&amp;modules=startup&amp;only=scripts&amp;raw=1&amp;skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=site.styles&amp;only=styles&amp;skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.18"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/d/d2/Square_join.png"> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="1201"> <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Square_join.png/800px-Square_join.png"> <meta property="og:image:width" content="800"> <meta property="og:image:height" content="801"> <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Square_join.png/640px-Square_join.png"> <meta property="og:image:width" content="640"> <meta property="og:image:height" content="641"> <meta name="viewport" content="width=1120"> <meta property="og:title" content="Join (SQL) - Wikipedia"> <meta property="og:type" content="website"> <link rel="preconnect" href="//upload.wikimedia.org"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//en.m.wikipedia.org/wiki/Join_(SQL)"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Join_(SQL)&amp;action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png"> <link rel="icon" href="/static/favicon/wikipedia.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wikipedia (en)"> <link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd"> <link rel="canonical" href="https://en.wikipedia.org/wiki/Join_(SQL)"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en"> <link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&amp;feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="login.wikimedia.org"> </head> <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject mw-editable page-Join_SQL rootpage-Join_SQL skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" title="Main menu" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Main menu" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Main menu</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Main menu</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Navigation </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/Main_Page" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-contents" class="mw-list-item"><a href="/wiki/Wikipedia:Contents" title="Guides to browsing Wikipedia"><span>Contents</span></a></li><li id="n-currentevents" class="mw-list-item"><a href="/wiki/Portal:Current_events" title="Articles related to current events"><span>Current events</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Special:Random" title="Visit a randomly selected article [x]" accesskey="x"><span>Random article</span></a></li><li id="n-aboutsite" class="mw-list-item"><a href="/wiki/Wikipedia:About" title="Learn about Wikipedia and how it works"><span>About Wikipedia</span></a></li><li id="n-contactpage" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us" title="How to contact Wikipedia"><span>Contact us</span></a></li> </ul> </div> </div> <div id="p-interaction" class="vector-menu mw-portlet mw-portlet-interaction" > <div class="vector-menu-heading"> Contribute </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-help" class="mw-list-item"><a href="/wiki/Help:Contents" title="Guidance on how to use and edit Wikipedia"><span>Help</span></a></li><li id="n-introduction" class="mw-list-item"><a href="/wiki/Help:Introduction" title="Learn how to edit Wikipedia"><span>Learn to edit</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Wikipedia:Community_portal" title="The hub for editors"><span>Community portal</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Special:RecentChanges" title="A list of recent changes to Wikipedia [r]" accesskey="r"><span>Recent changes</span></a></li><li id="n-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_upload_wizard" title="Add images or other media for use on Wikipedia"><span>Upload file</span></a></li><li id="n-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages"><span>Special pages</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/Main_Page" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="Wikipedia" src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" style="width: 7.5em; height: 1.125em;"> <img class="mw-logo-tagline" alt="The Free Encyclopedia" src="/static/images/mobile/copyright/wikipedia-tagline-en.svg" width="117" height="13" style="width: 7.3125em; height: 0.8125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Special:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Search Wikipedia [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Change the appearance of the page&#039;s font size, width, and color" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Appearance" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Appearance</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="https://donate.wikimedia.org/?wmf_source=donate&amp;wmf_medium=sidebar&amp;wmf_campaign=en.wikipedia.org&amp;uselang=en" class=""><span>Donate</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:CreateAccount&amp;returnto=Join+%28SQL%29" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:UserLogin&amp;returnto=Join+%28SQL%29" title="You&#039;re encouraged to log in; however, it&#039;s not mandatory. [o]" accesskey="o" class=""><span>Log in</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="Log in and more options" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Personal tools" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Personal tools</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="User menu" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="https://donate.wikimedia.org/?wmf_source=donate&amp;wmf_medium=sidebar&amp;wmf_campaign=en.wikipedia.org&amp;uselang=en"><span>Donate</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&amp;returnto=Join+%28SQL%29" title="You are encouraged to create an account and log in; however, it is not mandatory"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Create account</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:UserLogin&amp;returnto=Join+%28SQL%29" title="You&#039;re encouraged to log in; however, it&#039;s not mandatory. [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y"><span>Contributions</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n"><span>Talk</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Contents" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Contents</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">(Top)</div> </a> </li> <li id="toc-Example_tables" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Example_tables"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Example tables</span> </div> </a> <ul id="toc-Example_tables-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Cross_join" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Cross_join"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Cross join</span> </div> </a> <ul id="toc-Cross_join-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Inner_join" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Inner_join"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Inner join</span> </div> </a> <button aria-controls="toc-Inner_join-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Inner join subsection</span> </button> <ul id="toc-Inner_join-sublist" class="vector-toc-list"> <li id="toc-Inner_join_and_NULL_values" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Inner_join_and_NULL_values"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1</span> <span>Inner join and NULL values</span> </div> </a> <ul id="toc-Inner_join_and_NULL_values-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Equi-join" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Equi-join"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.2</span> <span>Equi-join</span> </div> </a> <ul id="toc-Equi-join-sublist" class="vector-toc-list"> <li id="toc-Natural_join" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Natural_join"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.2.1</span> <span>Natural join</span> </div> </a> <ul id="toc-Natural_join-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> </ul> </li> <li id="toc-Outer_join" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Outer_join"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Outer join</span> </div> </a> <button aria-controls="toc-Outer_join-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Outer join subsection</span> </button> <ul id="toc-Outer_join-sublist" class="vector-toc-list"> <li id="toc-Left_outer_join" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Left_outer_join"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1</span> <span>Left outer join</span> </div> </a> <ul id="toc-Left_outer_join-sublist" class="vector-toc-list"> <li id="toc-Alternative_syntaxes" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Alternative_syntaxes"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1.1</span> <span>Alternative syntaxes</span> </div> </a> <ul id="toc-Alternative_syntaxes-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Right_outer_join" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Right_outer_join"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2</span> <span>Right outer join</span> </div> </a> <ul id="toc-Right_outer_join-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Full_outer_join" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Full_outer_join"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.3</span> <span>Full outer join</span> </div> </a> <ul id="toc-Full_outer_join-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Self-join" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Self-join"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>Self-join</span> </div> </a> <button aria-controls="toc-Self-join-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Self-join subsection</span> </button> <ul id="toc-Self-join-sublist" class="vector-toc-list"> <li id="toc-Example" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Example"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1</span> <span>Example</span> </div> </a> <ul id="toc-Example-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Alternatives" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Alternatives"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Alternatives</span> </div> </a> <ul id="toc-Alternatives-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Implementation" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Implementation"> <div class="vector-toc-text"> <span class="vector-toc-numb">7</span> <span>Implementation</span> </div> </a> <button aria-controls="toc-Implementation-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Implementation subsection</span> </button> <ul id="toc-Implementation-sublist" class="vector-toc-list"> <li id="toc-Join_algorithms" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Join_algorithms"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.1</span> <span>Join algorithms</span> </div> </a> <ul id="toc-Join_algorithms-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Join_indexes" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Join_indexes"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.2</span> <span>Join indexes</span> </div> </a> <ul id="toc-Join_indexes-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Straight_join" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Straight_join"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.3</span> <span>Straight join</span> </div> </a> <ul id="toc-Straight_join-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-See_also" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#See_also"> <div class="vector-toc-text"> <span class="vector-toc-numb">8</span> <span>See also</span> </div> </a> <ul id="toc-See_also-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-References" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#References"> <div class="vector-toc-text"> <span class="vector-toc-numb">9</span> <span>References</span> </div> </a> <button aria-controls="toc-References-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle References subsection</span> </button> <ul id="toc-References-sublist" class="vector-toc-list"> <li id="toc-Citations" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Citations"> <div class="vector-toc-text"> <span class="vector-toc-numb">9.1</span> <span>Citations</span> </div> </a> <ul id="toc-Citations-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Sources" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Sources"> <div class="vector-toc-text"> <span class="vector-toc-numb">9.2</span> <span>Sources</span> </div> </a> <ul id="toc-Sources-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-External_links" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#External_links"> <div class="vector-toc-text"> <span class="vector-toc-numb">10</span> <span>External links</span> </div> </a> <ul id="toc-External_links-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" title="Table of Contents" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Join (SQL)</span></h1> <div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang" > <input type="checkbox" id="p-lang-btn-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-lang-btn" class="vector-dropdown-checkbox mw-interlanguage-selector" aria-label="Go to an article in another language. Available in 21 languages" > <label id="p-lang-btn-label" for="p-lang-btn-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive mw-portlet-lang-heading-21" aria-hidden="true" ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span> <span class="vector-dropdown-label-text">21 languages</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="interlanguage-link interwiki-az mw-list-item"><a href="https://az.wikipedia.org/wiki/Daxili_birl%C9%99%C5%9Fdirm%C9%99" title="Daxili birləşdirmə – Azerbaijani" lang="az" hreflang="az" data-title="Daxili birləşdirmə" data-language-autonym="Azərbaycanca" data-language-local-name="Azerbaijani" class="interlanguage-link-target"><span>Azərbaycanca</span></a></li><li class="interlanguage-link interwiki-ca mw-list-item"><a href="https://ca.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Catalan" lang="ca" hreflang="ca" data-title="Join (SQL)" data-language-autonym="Català" data-language-local-name="Catalan" class="interlanguage-link-target"><span>Català</span></a></li><li class="interlanguage-link interwiki-cs mw-list-item"><a href="https://cs.wikipedia.org/wiki/JOIN" title="JOIN – Czech" lang="cs" hreflang="cs" data-title="JOIN" data-language-autonym="Čeština" data-language-local-name="Czech" class="interlanguage-link-target"><span>Čeština</span></a></li><li class="interlanguage-link interwiki-da mw-list-item"><a href="https://da.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Danish" lang="da" hreflang="da" data-title="Join (SQL)" data-language-autonym="Dansk" data-language-local-name="Danish" class="interlanguage-link-target"><span>Dansk</span></a></li><li class="interlanguage-link interwiki-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – German" lang="de" hreflang="de" data-title="Join (SQL)" data-language-autonym="Deutsch" data-language-local-name="German" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-es mw-list-item"><a href="https://es.wikipedia.org/wiki/Sentencia_JOIN_en_SQL" title="Sentencia JOIN en SQL – Spanish" lang="es" hreflang="es" data-title="Sentencia JOIN en SQL" data-language-autonym="Español" data-language-local-name="Spanish" class="interlanguage-link-target"><span>Español</span></a></li><li class="interlanguage-link interwiki-fr mw-list-item"><a href="https://fr.wikipedia.org/wiki/Jointure_(informatique)" title="Jointure (informatique) – French" lang="fr" hreflang="fr" data-title="Jointure (informatique)" data-language-autonym="Français" data-language-local-name="French" class="interlanguage-link-target"><span>Français</span></a></li><li class="interlanguage-link interwiki-ko mw-list-item"><a href="https://ko.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Korean" lang="ko" hreflang="ko" data-title="Join (SQL)" data-language-autonym="한국어" data-language-local-name="Korean" class="interlanguage-link-target"><span>한국어</span></a></li><li class="interlanguage-link interwiki-hy mw-list-item"><a href="https://hy.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Armenian" lang="hy" hreflang="hy" data-title="Join (SQL)" data-language-autonym="Հայերեն" data-language-local-name="Armenian" class="interlanguage-link-target"><span>Հայերեն</span></a></li><li class="interlanguage-link interwiki-it mw-list-item"><a href="https://it.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Italian" lang="it" hreflang="it" data-title="Join (SQL)" data-language-autonym="Italiano" data-language-local-name="Italian" class="interlanguage-link-target"><span>Italiano</span></a></li><li class="interlanguage-link interwiki-he mw-list-item"><a href="https://he.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Hebrew" lang="he" hreflang="he" data-title="Join (SQL)" data-language-autonym="עברית" data-language-local-name="Hebrew" class="interlanguage-link-target"><span>עברית</span></a></li><li class="interlanguage-link interwiki-nl mw-list-item"><a href="https://nl.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Dutch" lang="nl" hreflang="nl" data-title="Join (SQL)" data-language-autonym="Nederlands" data-language-local-name="Dutch" class="interlanguage-link-target"><span>Nederlands</span></a></li><li class="interlanguage-link interwiki-no mw-list-item"><a href="https://no.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Norwegian Bokmål" lang="nb" hreflang="nb" data-title="Join (SQL)" data-language-autonym="Norsk bokmål" data-language-local-name="Norwegian Bokmål" class="interlanguage-link-target"><span>Norsk bokmål</span></a></li><li class="interlanguage-link interwiki-pl mw-list-item"><a href="https://pl.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Polish" lang="pl" hreflang="pl" data-title="Join (SQL)" data-language-autonym="Polski" data-language-local-name="Polish" class="interlanguage-link-target"><span>Polski</span></a></li><li class="interlanguage-link interwiki-pt mw-list-item"><a href="https://pt.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Portuguese" lang="pt" hreflang="pt" data-title="Join (SQL)" data-language-autonym="Português" data-language-local-name="Portuguese" class="interlanguage-link-target"><span>Português</span></a></li><li class="interlanguage-link interwiki-ru mw-list-item"><a href="https://ru.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Russian" lang="ru" hreflang="ru" data-title="Join (SQL)" data-language-autonym="Русский" data-language-local-name="Russian" class="interlanguage-link-target"><span>Русский</span></a></li><li class="interlanguage-link interwiki-simple mw-list-item"><a href="https://simple.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Simple English" lang="en-simple" hreflang="en-simple" data-title="Join (SQL)" data-language-autonym="Simple English" data-language-local-name="Simple English" class="interlanguage-link-target"><span>Simple English</span></a></li><li class="interlanguage-link interwiki-sr mw-list-item"><a href="https://sr.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Serbian" lang="sr" hreflang="sr" data-title="Join (SQL)" data-language-autonym="Српски / srpski" data-language-local-name="Serbian" class="interlanguage-link-target"><span>Српски / srpski</span></a></li><li class="interlanguage-link interwiki-uk mw-list-item"><a href="https://uk.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Ukrainian" lang="uk" hreflang="uk" data-title="Join (SQL)" data-language-autonym="Українська" data-language-local-name="Ukrainian" class="interlanguage-link-target"><span>Українська</span></a></li><li class="interlanguage-link interwiki-vi mw-list-item"><a href="https://vi.wikipedia.org/wiki/Join_(SQL)" title="Join (SQL) – Vietnamese" lang="vi" hreflang="vi" data-title="Join (SQL)" data-language-autonym="Tiếng Việt" data-language-local-name="Vietnamese" class="interlanguage-link-target"><span>Tiếng Việt</span></a></li><li class="interlanguage-link interwiki-zh mw-list-item"><a href="https://zh.wikipedia.org/wiki/%E8%BF%9E%E6%8E%A5" title="连接 – Chinese" lang="zh" hreflang="zh" data-title="连接" data-language-autonym="中文" data-language-local-name="Chinese" class="interlanguage-link-target"><span>中文</span></a></li> </ul> <div class="after-portlet after-portlet-lang"><span class="wb-langlinks-edit wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q2003535#sitelinks-wikipedia" title="Edit interlanguage links" class="wbc-editpage">Edit links</a></span></div> </div> </div> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Namespaces"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-main" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Join_(SQL)" title="View the content page [c]" accesskey="c"><span>Article</span></a></li><li id="ca-talk" class="vector-tab-noicon mw-list-item"><a href="/wiki/Talk:Join_(SQL)" rel="discussion" title="Discuss improvements to the content page [t]" accesskey="t"><span>Talk</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Change language variant" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Views"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Join_(SQL)"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Join_(SQL)&amp;action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Join_(SQL)&amp;action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Tools" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Tools</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Tools</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="More options" > <div class="vector-menu-heading"> Actions </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Join_(SQL)"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Join_(SQL)&amp;action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Join_(SQL)&amp;action=history"><span>View history</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> General </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Join_(SQL)" title="List of all English Wikipedia pages containing links to this page [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Special:RecentChangesLinked/Join_(SQL)" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-upload" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Join_(SQL)&amp;oldid=1274538111" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Join_(SQL)&amp;action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-cite" class="mw-list-item"><a href="/w/index.php?title=Special:CiteThisPage&amp;page=Join_%28SQL%29&amp;id=1274538111&amp;wpFormIdentifier=titleform" title="Information on how to cite this page"><span>Cite this page</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&amp;url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FJoin_%28SQL%29"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&amp;url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FJoin_%28SQL%29"><span>Download QR code</span></a></li> </ul> </div> </div> <div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export" > <div class="vector-menu-heading"> Print/export </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&amp;page=Join_%28SQL%29&amp;action=show-download-screen" title="Download this page as a PDF file"><span>Download as PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="/w/index.php?title=Join_(SQL)&amp;printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects" > <div class="vector-menu-heading"> In other projects </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="wb-otherproject-link wb-otherproject-commons mw-list-item"><a href="https://commons.wikimedia.org/wiki/Category:SQL_Joins" hreflang="en"><span>Wikimedia Commons</span></a></li><li id="t-wikibase" class="wb-otherproject-link wb-otherproject-wikibase-dataitem mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q2003535" title="Structured data on this page hosted by Wikidata [g]" accesskey="g"><span>Wikidata item</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Appearance</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">hide</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div class="mw-indicators"> </div> <div id="siteSub" class="noprint">From Wikipedia, the free encyclopedia</div> </div> <div id="contentSub"><div id="mw-content-subtitle"></div></div> <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><div class="shortdescription nomobile noexcerpt noprint searchaux" style="display:none">SQL clause</div> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Square_join.png" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Square_join.png/220px-Square_join.png" decoding="async" width="220" height="220" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Square_join.png/330px-Square_join.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Square_join.png/440px-Square_join.png 2x" data-file-width="987" data-file-height="988" /></a><figcaption>A <a href="/wiki/Venn_diagram" title="Venn diagram">Venn diagram</a> representing the full join SQL statement between tables A and B.</figcaption></figure> <p>A <b>join</b> clause in the Structured Query Language (<a href="/wiki/SQL" title="SQL">SQL</a>) combines <a href="/wiki/Column_(database)" title="Column (database)">columns</a> from one or more <a href="/wiki/Table_(database)" title="Table (database)">tables</a> into a new table. The operation corresponds to a <a href="/wiki/Join_(relational_algebra)" class="mw-redirect" title="Join (relational algebra)">join operation in relational algebra</a>. Informally, a join stitches two tables and puts on the same row records with matching fields&#160;: <code>INNER</code>, <code>LEFT OUTER</code>, <code>RIGHT OUTER</code>, <code>FULL OUTER</code> and <code>CROSS</code>. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="Example_tables">Example tables</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=1" title="Edit section: Example tables"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>To explain join types, the rest of this article uses the following tables: </p> <table class="wikitable" style="text-align:center; float:left; margin-right:5px"> <caption>Employee table </caption> <tbody><tr> <th>LastName</th> <th>DepartmentID </th></tr> <tr> <td>Rafferty</td> <td>31 </td></tr> <tr> <td>Jones</td> <td>33 </td></tr> <tr> <td>Heisenberg</td> <td>33 </td></tr> <tr> <td>Robinson</td> <td>34 </td></tr> <tr> <td>Smith</td> <td>34 </td></tr> <tr> <td>Williams</td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code> </td></tr></tbody></table> <table class="wikitable" style="text-align:center; float:left; margin-left:5px"> <caption>Department table </caption> <tbody><tr> <th>DepartmentID</th> <th>DepartmentName </th></tr> <tr> <td>31</td> <td>Sales </td></tr> <tr> <td>33</td> <td>Engineering </td></tr> <tr> <td>34</td> <td>Clerical </td></tr> <tr> <td>35</td> <td>Marketing </td></tr></tbody></table> <div style="clear:both;" class=""></div> <p><code>Department.DepartmentID</code> is the <a href="/wiki/Primary_key" title="Primary key">primary key</a> of the <code>Department</code> table, whereas <code>Employee.DepartmentID</code> is a <a href="/wiki/Foreign_key" title="Foreign key">foreign key</a>. </p><p>Note that in <code>Employee</code>, "Williams" has not yet been assigned to a department. Also, no employees have been assigned to the "Marketing" department. </p><p>These are the SQL statements to create the above tables: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span></span><span class="linenos" data-line="1"></span><span class="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">department</span><span class="p">(</span> <span class="linenos" data-line="2"></span><span class="w"> </span><span class="n">DepartmentID</span><span class="w"> </span><span class="nb">INT</span><span class="w"> </span><span class="k">PRIMARY</span><span class="w"> </span><span class="k">KEY</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">NULL</span><span class="p">,</span> <span class="linenos" data-line="3"></span><span class="w"> </span><span class="n">DepartmentName</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span> <span class="linenos" data-line="4"></span><span class="p">);</span> <span class="linenos" data-line="5"></span> <span class="linenos" data-line="6"></span><span class="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">employee</span><span class="w"> </span><span class="p">(</span> <span class="linenos" data-line="7"></span><span class="w"> </span><span class="n">LastName</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">20</span><span class="p">),</span> <span class="linenos" data-line="8"></span><span class="w"> </span><span class="n">DepartmentID</span><span class="w"> </span><span class="nb">INT</span><span class="w"> </span><span class="k">REFERENCES</span><span class="w"> </span><span class="n">department</span><span class="p">(</span><span class="n">DepartmentID</span><span class="p">)</span> <span class="linenos" data-line="9"></span><span class="p">);</span> <span class="linenos" data-line="10"></span> <span class="linenos" data-line="11"></span><span class="k">INSERT</span><span class="w"> </span><span class="k">INTO</span><span class="w"> </span><span class="n">department</span> <span class="linenos" data-line="12"></span><span class="k">VALUES</span><span class="w"> </span><span class="p">(</span><span class="mi">31</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;Sales&#39;</span><span class="p">),</span> <span class="linenos" data-line="13"></span><span class="w"> </span><span class="p">(</span><span class="mi">33</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;Engineering&#39;</span><span class="p">),</span> <span class="linenos" data-line="14"></span><span class="w"> </span><span class="p">(</span><span class="mi">34</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;Clerical&#39;</span><span class="p">),</span> <span class="linenos" data-line="15"></span><span class="w"> </span><span class="p">(</span><span class="mi">35</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;Marketing&#39;</span><span class="p">);</span> <span class="linenos" data-line="16"></span> <span class="linenos" data-line="17"></span><span class="k">INSERT</span><span class="w"> </span><span class="k">INTO</span><span class="w"> </span><span class="n">employee</span> <span class="linenos" data-line="18"></span><span class="k">VALUES</span><span class="w"> </span><span class="p">(</span><span class="s1">&#39;Rafferty&#39;</span><span class="p">,</span><span class="w"> </span><span class="mi">31</span><span class="p">),</span> <span class="linenos" data-line="19"></span><span class="w"> </span><span class="p">(</span><span class="s1">&#39;Jones&#39;</span><span class="p">,</span><span class="w"> </span><span class="mi">33</span><span class="p">),</span> <span class="linenos" data-line="20"></span><span class="w"> </span><span class="p">(</span><span class="s1">&#39;Heisenberg&#39;</span><span class="p">,</span><span class="w"> </span><span class="mi">33</span><span class="p">),</span> <span class="linenos" data-line="21"></span><span class="w"> </span><span class="p">(</span><span class="s1">&#39;Robinson&#39;</span><span class="p">,</span><span class="w"> </span><span class="mi">34</span><span class="p">),</span> <span class="linenos" data-line="22"></span><span class="w"> </span><span class="p">(</span><span class="s1">&#39;Smith&#39;</span><span class="p">,</span><span class="w"> </span><span class="mi">34</span><span class="p">),</span> <span class="linenos" data-line="23"></span><span class="w"> </span><span class="p">(</span><span class="s1">&#39;Williams&#39;</span><span class="p">,</span><span class="w"> </span><span class="k">NULL</span><span class="p">);</span> </pre></div> <div class="mw-heading mw-heading2"><h2 id="Cross_join">Cross join</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=2" title="Edit section: Cross join"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><code>CROSS JOIN</code> returns the <a href="/wiki/Cartesian_product" title="Cartesian product">Cartesian product</a> of rows from tables in the join. In other words, it will produce rows which combine each row from the first table with each row from the second table.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup> </p> <table class="wikitable" style="text-align:center"> <tbody><tr> <th>Employee.LastName</th> <th>Employee.DepartmentID</th> <th>Department.DepartmentName</th> <th>Department.DepartmentID </th></tr> <tr> <td>Rafferty</td> <td>31</td> <td>Sales</td> <td>31 </td></tr> <tr> <td>Jones</td> <td>33</td> <td>Sales</td> <td>31 </td></tr> <tr> <td>Heisenberg</td> <td>33</td> <td>Sales</td> <td>31 </td></tr> <tr> <td>Smith</td> <td>34</td> <td>Sales</td> <td>31 </td></tr> <tr> <td>Robinson</td> <td>34</td> <td>Sales</td> <td>31 </td></tr> <tr> <td>Williams</td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td>Sales</td> <td>31 </td></tr> <tr> <td>Rafferty</td> <td>31</td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Jones</td> <td>33</td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Heisenberg</td> <td>33</td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Smith</td> <td>34</td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Robinson</td> <td>34</td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Williams</td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Rafferty</td> <td>31</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td>Jones</td> <td>33</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td>Heisenberg</td> <td>33</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td>Smith</td> <td>34</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td>Robinson</td> <td>34</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td>Williams</td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td>Clerical</td> <td>34 </td></tr> <tr> <td>Rafferty</td> <td>31</td> <td>Marketing</td> <td>35 </td></tr> <tr> <td>Jones</td> <td>33</td> <td>Marketing</td> <td>35 </td></tr> <tr> <td>Heisenberg</td> <td>33</td> <td>Marketing</td> <td>35 </td></tr> <tr> <td>Smith</td> <td>34</td> <td>Marketing</td> <td>35 </td></tr> <tr> <td>Robinson</td> <td>34</td> <td>Marketing</td> <td>35 </td></tr> <tr> <td>Williams</td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td>Marketing</td> <td>35 </td></tr></tbody></table> <p>Example of an explicit cross join: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="w"> </span><span class="k">CROSS</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span><span class="p">;</span> </pre></div> <p>Example of an implicit cross join: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="p">,</span><span class="w"> </span><span class="n">department</span><span class="p">;</span> </pre></div><p>The cross join can be replaced with an inner join with an always-true condition:</p><div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="w"> </span><span class="k">INNER</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span><span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="mi">1</span><span class="o">=</span><span class="mi">1</span><span class="p">;</span> </pre></div> <p><code>CROSS JOIN</code> does not itself apply any predicate to filter rows from the joined table. The results of a <code>CROSS JOIN</code> can be filtered using a <code>WHERE</code> clause, which may then produce the equivalent of an inner join. </p><p>In the <a href="/wiki/SQL:2011" title="SQL:2011">SQL:2011</a> standard, cross joins are part of the optional F401, "Extended joined table", package. </p><p>Normal uses are for checking the server's performance.<sup class="noprint Inline-Template" style="white-space:nowrap;">&#91;<i><a href="/wiki/Wikipedia:Please_clarify" title="Wikipedia:Please clarify"><span title="The reason for this is unclear. (May 2021)">why?</span></a></i>&#93;</sup> </p> <div class="mw-heading mw-heading2"><h2 id="Inner_join">Inner join</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=3" title="Edit section: Inner join"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>An <b>inner join</b> (or <b>join</b>) requires each row in the two joined tables to have matching column values, and is a commonly used join operation in <a href="/wiki/Application_software" title="Application software">applications</a> but should not be assumed to be the best choice in all situations. Inner join creates a new result table by combining column values of two tables (A and B) based upon the join-predicate. The query compares each row of A with each row of B to find all pairs of rows that satisfy the join-predicate. When the join-predicate is satisfied by matching non-<a href="/wiki/Null_(SQL)" title="Null (SQL)">NULL</a> values, column values for each matched pair of rows of A and B are combined into a result row. </p><p>The result of the join can be defined as the outcome of first taking the <a href="/wiki/Cartesian_product" title="Cartesian product">cartesian product</a> (or <a href="#Cross_join">cross join</a>) of all rows in the tables (combining every row in table A with every row in table B) and then returning all rows that satisfy the join predicate. Actual SQL implementations normally use other approaches, such as <a href="/wiki/Hash_join" title="Hash join">hash joins</a> or <a href="/wiki/Sort-merge_join" title="Sort-merge join">sort-merge joins</a>, since computing the Cartesian product is slower and would often require a prohibitively large amount of memory to store. </p><p>SQL specifies two different syntactical ways to express joins: the "explicit join notation" and the "implicit join notation". The "implicit join notation" is no longer considered a best practice<sup class="noprint Inline-Template" style="white-space:nowrap;">&#91;<i><a href="/wiki/Wikipedia:Manual_of_Style/Words_to_watch#Unsupported_attributions" title="Wikipedia:Manual of Style/Words to watch"><span title="The material near this tag may use weasel words or too-vague attribution. (September 2022)">by whom?</span></a></i>&#93;</sup>, although database systems still support it. </p><p>The "explicit join notation" uses the <code>JOIN</code> keyword, optionally preceded by the <code>INNER</code> keyword, to specify the table to join, and the <code>ON</code> keyword to specify the predicates for the join, as in the following example: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">LastName</span><span class="p">,</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">,</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentName</span><span class="w"> </span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="w"> </span> <span class="k">INNER</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span><span class="w"> </span><span class="k">ON</span> <span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">;</span> </pre></div> <table class="wikitable"> <tbody><tr> <th>Employee.LastName</th> <th>Employee.DepartmentID</th> <th>Department.DepartmentName </th></tr> <tr> <td>Robinson</td> <td>34</td> <td>Clerical </td></tr> <tr> <td>Jones</td> <td>33</td> <td>Engineering </td></tr> <tr> <td>Smith</td> <td>34</td> <td>Clerical </td></tr> <tr> <td>Heisenberg</td> <td>33</td> <td>Engineering </td></tr> <tr> <td>Rafferty</td> <td>31</td> <td>Sales </td></tr></tbody></table> <p>The "implicit join notation" simply lists the tables for joining, in the <code>FROM</code> clause of the <code>SELECT</code> statement, using commas to separate them. Thus it specifies a <a href="#Cross_join">cross join</a>, and the <code>WHERE</code> clause may apply additional filter-predicates (which function comparably to the join-predicates in the explicit notation). </p><p>The following example is equivalent to the previous one, but this time using implicit join notation: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">LastName</span><span class="p">,</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">,</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentName</span><span class="w"> </span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="p">,</span><span class="w"> </span><span class="n">department</span> <span class="k">WHERE</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">;</span> </pre></div> <p>The queries given in the examples above will join the Employee and department tables using the DepartmentID column of both tables. Where the DepartmentID of these tables match (i.e. the join-predicate is satisfied), the query will combine the <i>LastName</i>, <i>DepartmentID</i> and <i>DepartmentName</i> columns from the two tables into a result row. Where the DepartmentID does not match, no result row is generated. </p><p>Thus the result of the <a href="/wiki/Query_plan" title="Query plan">execution</a> of the query above will be: </p> <table class="wikitable"> <tbody><tr> <th>Employee.LastName</th> <th>Employee.DepartmentID</th> <th>Department.DepartmentName </th></tr> <tr> <td>Robinson</td> <td>34</td> <td>Clerical </td></tr> <tr> <td>Jones</td> <td>33</td> <td>Engineering </td></tr> <tr> <td>Smith</td> <td>34</td> <td>Clerical </td></tr> <tr> <td>Heisenberg</td> <td>33</td> <td>Engineering </td></tr> <tr> <td>Rafferty</td> <td>31</td> <td>Sales </td></tr></tbody></table> <p>The employee "Williams" and the department "Marketing" do not appear in the query execution results. Neither of these has any matching rows in the other respective table: "Williams" has no associated department, and no employee has the department ID 35 ("Marketing"). Depending on the desired results, this behavior may be a subtle bug, which can be avoided by replacing the inner join with an <a href="#Outer_join">outer join</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Inner_join_and_NULL_values">Inner join and NULL values</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=4" title="Edit section: Inner join and NULL values"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Programmers should take special care when joining tables on columns that can contain <a href="/wiki/Null_(SQL)" title="Null (SQL)">NULL</a> values, since NULL will never match any other value (not even NULL itself), unless the join condition explicitly uses a combination predicate that first checks that the joins columns are <code> NOT NULL</code> before applying the remaining predicate condition(s). The Inner Join can only be safely used in a database that enforces <a href="/wiki/Referential_integrity" title="Referential integrity">referential integrity</a> or where the join columns are guaranteed not to be NULL. Many <a href="/wiki/Transaction_processing" title="Transaction processing">transaction processing</a> relational databases rely on <a href="/wiki/ACID" title="ACID">atomicity, consistency, isolation, durability</a> (ACID) data update standards to ensure data integrity, making inner joins an appropriate choice. However, transaction databases usually also have desirable join columns that are allowed to be NULL. Many reporting relational database and <a href="/wiki/Data_warehouse" title="Data warehouse">data warehouses</a> use high volume <a href="/wiki/Extract,_transform,_load" title="Extract, transform, load">extract, transform, load</a> (ETL) batch updates which make referential integrity difficult or impossible to enforce, resulting in potentially NULL join columns that an SQL query author cannot modify and which cause inner joins to omit data with no indication of an error. The choice to use an inner join depends on the database design and data characteristics. A left outer join can usually be substituted for an inner join when the join columns in one table may contain NULL values. </p><p>Any data column that may be NULL (empty) should never be used as a link in an inner join, unless the intended result is to eliminate the rows with the NULL value. If NULL join columns are to be deliberately removed from the <a href="/wiki/Result_set" title="Result set">result set</a>, an inner join can be faster than an outer join because the table join and filtering is done in a single step. Conversely, an inner join can result in disastrously slow performance or even a server crash when used in a large volume query in combination with database functions in an SQL Where clause.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>3<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>4<span class="cite-bracket">&#93;</span></a></sup> A function in an SQL Where clause can result in the database ignoring relatively compact table indexes. The database may read and inner join the selected columns from both tables before reducing the number of rows using the filter that depends on a calculated value, resulting in a relatively enormous amount of inefficient processing. </p><p>When a result set is produced by joining several tables, including master tables used to look up full-text descriptions of numeric identifier codes (a <a href="/wiki/Lookup_table" title="Lookup table">Lookup table</a>), a NULL value in any one of the foreign keys can result in the entire row being eliminated from the result set, with no indication of error. A complex SQL query that includes one or more inner joins and several outer joins has the same risk for NULL values in the inner join link columns. </p><p>A commitment to SQL code containing inner joins assumes NULL join columns will not be introduced by future changes, including vendor updates, design changes and bulk processing outside of the application's data validation rules such as data conversions, migrations, bulk imports and merges. </p><p>One can further classify inner joins as equi-joins, as natural joins, or as cross-joins. </p> <div class="mw-heading mw-heading3"><h3 id="Equi-join">Equi-join</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=5" title="Edit section: Equi-join"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>An <b>equi-join</b> is a specific type of comparator-based join, that uses only <a href="/wiki/Equality_(mathematics)" title="Equality (mathematics)">equality</a> comparisons in the join-predicate. Using other comparison operators (such as <code>&lt;</code>) disqualifies a join as an equi-join. The query shown above has already provided an example of an equi-join: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span> <span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">;</span> </pre></div> <p>We can write equi-join as below, </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="p">,</span><span class="w"> </span><span class="n">department</span> <span class="k">WHERE</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">;</span> </pre></div> <p>If columns in an equi-join have the same name, <a href="/wiki/SQL-92" title="SQL-92">SQL-92</a> provides an optional shorthand notation for expressing equi-joins, by way of the <code>USING</code> construct:<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">&#91;</span>5<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="w"> </span><span class="k">INNER</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span><span class="w"> </span><span class="k">USING</span><span class="w"> </span><span class="p">(</span><span class="n">DepartmentID</span><span class="p">);</span> </pre></div> <p>The <code>USING</code> construct is more than mere <a href="/wiki/Syntactic_sugar" title="Syntactic sugar">syntactic sugar</a>, however, since the result set differs from the result set of the version with the explicit predicate. Specifically, any columns mentioned in the <code>USING</code> list will appear only once, with an unqualified name, rather than once for each table in the join. In the case above, there will be a single <code>DepartmentID</code> column and no <code>employee.DepartmentID</code> or <code>department.DepartmentID</code>. </p><p>The <code>USING</code> clause is not supported by MS SQL Server and Sybase. </p> <div class="mw-heading mw-heading4"><h4 id="Natural_join"><span class="anchor" id="Natural_join_in_inner_join"></span>Natural join</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=6" title="Edit section: Natural join"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The natural join is a special case of equi-join. Natural join (⋈) is a <a href="/wiki/Binary_relation" title="Binary relation">binary operator</a> that is written as (<i>R</i> ⋈ <i>S</i>) where <i>R</i> and <i>S</i> are <a href="/wiki/Relation_(database)" title="Relation (database)">relations</a>.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">&#91;</span>6<span class="cite-bracket">&#93;</span></a></sup> The result of the natural join is the set of all combinations of <a href="/wiki/Tuples" class="mw-redirect" title="Tuples">tuples</a> in <i>R</i> and <i>S</i> that are equal on their common attribute names. For an example consider the tables <i>Employee</i> and <i>Dept</i> and their natural join: </p> <table style="margin: 0 auto;" cellpadding="20"> <tbody><tr valign="top"> <td> <table class="wikitable"> <caption><i>Employee</i> </caption> <tbody><tr> <th>Name</th> <th>EmpId</th> <th>DeptName </th></tr> <tr> <td>Harry</td> <td>3415</td> <td>Finance </td></tr> <tr> <td>Sally</td> <td>2241</td> <td>Sales </td></tr> <tr> <td>George</td> <td>3401</td> <td>Finance </td></tr> <tr> <td>Harriet</td> <td>2202</td> <td>Sales </td></tr></tbody></table> </td> <td> <table class="wikitable"> <caption><i>Dept</i> </caption> <tbody><tr> <th>DeptName</th> <th>Manager </th></tr> <tr> <td>Finance</td> <td>George </td></tr> <tr> <td>Sales</td> <td>Harriet </td></tr> <tr> <td>Production</td> <td>Charles </td></tr></tbody></table> </td> <td> <table class="wikitable"> <caption><i>Employee</i>&#160;<span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \bowtie }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo>&#x22c8;<!-- ⋈ --></mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \bowtie }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/bc29b9e87e8e88d9e1f70a95c08676c3e59976e0" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.091ex; height:1.843ex;" alt="{\displaystyle \bowtie }" /></span>&#160;<i>Dept</i> </caption> <tbody><tr> <th>Name</th> <th>EmpId</th> <th>DeptName</th> <th>Manager </th></tr> <tr> <td>Harry</td> <td>3415</td> <td>Finance</td> <td>George </td></tr> <tr> <td>Sally</td> <td>2241</td> <td>Sales</td> <td>Harriet </td></tr> <tr> <td>George</td> <td>3401</td> <td>Finance</td> <td>George </td></tr> <tr> <td>Harriet</td> <td>2202</td> <td>Sales</td> <td>Harriet </td></tr></tbody></table> </td></tr></tbody></table> <p>This can also be used to define <a href="/wiki/Composition_of_relations" title="Composition of relations">composition of relations</a>. For example, the composition of <i>Employee</i> and <i>Dept</i> is their join as shown above, projected on all but the common attribute <i>DeptName</i>. In <a href="/wiki/Category_theory" title="Category theory">category theory</a>, the join is precisely the <a href="/wiki/Fiber_product" class="mw-redirect" title="Fiber product">fiber product</a>. </p><p>The natural join is arguably one of the most important operators since it is the relational counterpart of logical AND. Note that if the same variable appears in each of two predicates that are connected by AND, then that variable stands for the same thing and both appearances must always be substituted by the same value. In particular, the natural join allows the combination of relations that are associated by a <a href="/wiki/Foreign_key" title="Foreign key">foreign key</a>. For example, in the above example a foreign key probably holds from <i>Employee</i>.<i>DeptName</i> to <i>Dept</i>.<i>DeptName</i> and then the natural join of <i>Employee</i> and <i>Dept</i> combines all employees with their departments. This works because the foreign key holds between attributes with the same name. If this is not the case such as in the foreign key from <i>Dept</i>.<i>manager</i> to <i>Employee</i>.<i>Name</i> then these columns have to be renamed before the natural join is taken. Such a join is sometimes also referred to as an <b>equi-join</b>. </p><p>More formally the semantics of the natural join are defined as follows: </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle R\bowtie S=\left\{t\cup s\mid t\in R\ \land \ s\in S\ \land \ {\mathit {Fun}}(t\cup s)\right\}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>R</mi> <mo>&#x22c8;<!-- ⋈ --></mo> <mi>S</mi> <mo>=</mo> <mrow> <mo>{</mo> <mrow> <mi>t</mi> <mo>&#x222a;<!-- ∪ --></mo> <mi>s</mi> <mo>&#x2223;<!-- ∣ --></mo> <mi>t</mi> <mo>&#x2208;<!-- ∈ --></mo> <mi>R</mi> <mtext>&#xa0;</mtext> <mo>&#x2227;<!-- ∧ --></mo> <mtext>&#xa0;</mtext> <mi>s</mi> <mo>&#x2208;<!-- ∈ --></mo> <mi>S</mi> <mtext>&#xa0;</mtext> <mo>&#x2227;<!-- ∧ --></mo> <mtext>&#xa0;</mtext> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mi class="MJX-tex-mathit" mathvariant="italic">F</mi> <mi class="MJX-tex-mathit" mathvariant="italic">u</mi> <mi class="MJX-tex-mathit" mathvariant="italic">n</mi> </mrow> </mrow> <mo stretchy="false">(</mo> <mi>t</mi> <mo>&#x222a;<!-- ∪ --></mo> <mi>s</mi> <mo stretchy="false">)</mo> </mrow> <mo>}</mo> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle R\bowtie S=\left\{t\cup s\mid t\in R\ \land \ s\in S\ \land \ {\mathit {Fun}}(t\cup s)\right\}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1a32d7c5edd7c2cf320c29baa98fd856b0d87d60" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:47.275ex; height:2.843ex;" alt="{\displaystyle R\bowtie S=\left\{t\cup s\mid t\in R\ \land \ s\in S\ \land \ {\mathit {Fun}}(t\cup s)\right\}}" /></span>,</dd></dl> <p>where <i>Fun</i> is a <a href="/wiki/Predicate_(mathematics)" class="mw-redirect" title="Predicate (mathematics)">predicate</a> that is true for a <a href="/wiki/Relation_(mathematics)" title="Relation (mathematics)">relation</a> <i>r</i> <a href="/wiki/If_and_only_if" title="If and only if">if and only if</a> <i>r</i> is a function. It is usually required that <i>R</i> and <i>S</i> must have at least one common attribute, but if this constraint is omitted, and <i>R</i> and <i>S</i> have no common attributes, then the natural join becomes exactly the Cartesian product. </p><p>The natural join can be simulated with Codd's primitives as follows. Let <i>c</i><sub>1</sub>, ..., <i>c</i><sub><i>m</i></sub> be the attribute names common to <i>R</i> and <i>S</i>, <i>r</i><sub>1</sub>, ..., <i>r</i><sub><i>n</i></sub> be the attribute names unique to <i>R</i> and let <i>s</i><sub>1</sub>, ..., <i>s</i><sub><i>k</i></sub> be the attributes unique to <i>S</i>. Furthermore, assume that the attribute names <i>x</i><sub>1</sub>, ..., <i>x</i><sub><i>m</i></sub> are neither in <i>R</i> nor in <i>S</i>. In a first step the common attribute names in <i>S</i> can now be renamed: </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T=\rho _{x_{1}/c_{1},\ldots ,x_{m}/c_{m}}(S)=\rho _{x_{1}/c_{1}}(\rho _{x_{2}/c_{2}}(\ldots \rho _{x_{m}/c_{m}}(S)\ldots ))}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>T</mi> <mo>=</mo> <msub> <mi>&#x3c1;<!-- ρ --></mi> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>x</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>1</mn> </mrow> </msub> <mrow class="MJX-TeXAtom-ORD"> <mo>/</mo> </mrow> <msub> <mi>c</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>1</mn> </mrow> </msub> <mo>,</mo> <mo>&#x2026;<!-- … --></mo> <mo>,</mo> <msub> <mi>x</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>m</mi> </mrow> </msub> <mrow class="MJX-TeXAtom-ORD"> <mo>/</mo> </mrow> <msub> <mi>c</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>m</mi> </mrow> </msub> </mrow> </msub> <mo stretchy="false">(</mo> <mi>S</mi> <mo stretchy="false">)</mo> <mo>=</mo> <msub> <mi>&#x3c1;<!-- ρ --></mi> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>x</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>1</mn> </mrow> </msub> <mrow class="MJX-TeXAtom-ORD"> <mo>/</mo> </mrow> <msub> <mi>c</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>1</mn> </mrow> </msub> </mrow> </msub> <mo stretchy="false">(</mo> <msub> <mi>&#x3c1;<!-- ρ --></mi> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>x</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msub> <mrow class="MJX-TeXAtom-ORD"> <mo>/</mo> </mrow> <msub> <mi>c</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msub> </mrow> </msub> <mo stretchy="false">(</mo> <mo>&#x2026;<!-- … --></mo> <msub> <mi>&#x3c1;<!-- ρ --></mi> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>x</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>m</mi> </mrow> </msub> <mrow class="MJX-TeXAtom-ORD"> <mo>/</mo> </mrow> <msub> <mi>c</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>m</mi> </mrow> </msub> </mrow> </msub> <mo stretchy="false">(</mo> <mi>S</mi> <mo stretchy="false">)</mo> <mo>&#x2026;<!-- … --></mo> <mo stretchy="false">)</mo> <mo stretchy="false">)</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle T=\rho _{x_{1}/c_{1},\ldots ,x_{m}/c_{m}}(S)=\rho _{x_{1}/c_{1}}(\rho _{x_{2}/c_{2}}(\ldots \rho _{x_{m}/c_{m}}(S)\ldots ))}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/5c591661e5ae892fb99445827839f9b208846f67" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.171ex; width:55.569ex; height:3.176ex;" alt="{\displaystyle T=\rho _{x_{1}/c_{1},\ldots ,x_{m}/c_{m}}(S)=\rho _{x_{1}/c_{1}}(\rho _{x_{2}/c_{2}}(\ldots \rho _{x_{m}/c_{m}}(S)\ldots ))}" /></span></dd></dl> <p>Then we take the Cartesian product and select the tuples that are to be joined: </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle U=\pi _{r_{1},\ldots ,r_{n},c_{1},\ldots ,c_{m},s_{1},\ldots ,s_{k}}(P)}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>U</mi> <mo>=</mo> <msub> <mi>&#x3c0;<!-- π --></mi> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>r</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>1</mn> </mrow> </msub> <mo>,</mo> <mo>&#x2026;<!-- … --></mo> <mo>,</mo> <msub> <mi>r</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> </mrow> </msub> <mo>,</mo> <msub> <mi>c</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>1</mn> </mrow> </msub> <mo>,</mo> <mo>&#x2026;<!-- … --></mo> <mo>,</mo> <msub> <mi>c</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>m</mi> </mrow> </msub> <mo>,</mo> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>1</mn> </mrow> </msub> <mo>,</mo> <mo>&#x2026;<!-- … --></mo> <mo>,</mo> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>k</mi> </mrow> </msub> </mrow> </msub> <mo stretchy="false">(</mo> <mi>P</mi> <mo stretchy="false">)</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle U=\pi _{r_{1},\ldots ,r_{n},c_{1},\ldots ,c_{m},s_{1},\ldots ,s_{k}}(P)}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/ec46ccaf1759695d27a262472a23ad8b118ea83d" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:29.533ex; height:3.009ex;" alt="{\displaystyle U=\pi _{r_{1},\ldots ,r_{n},c_{1},\ldots ,c_{m},s_{1},\ldots ,s_{k}}(P)}" /></span></dd></dl> <p>A <a href="/wiki/Natural_join" class="mw-redirect" title="Natural join">natural join</a> is a type of equi-join where the <b>join</b> predicate arises implicitly by comparing all columns in both tables that have the same column-names in the joined tables. The resulting joined table contains only one column for each pair of equally named columns. In the case that no columns with the same names are found, the result is a <a href="/wiki/Cross_join" class="mw-redirect" title="Cross join">cross join</a>. </p><p>Most experts agree that NATURAL JOINs are dangerous and therefore strongly discourage their use.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">&#91;</span>7<span class="cite-bracket">&#93;</span></a></sup> The danger comes from inadvertently adding a new column, named the same as another column in the other table. An existing natural join might then "naturally" use the new column for comparisons, making comparisons/matches using different criteria (from different columns) than before. Thus an existing query could produce different results, even though the data in the tables have not been changed, but only augmented. The use of column names to automatically determine table links is not an option in large databases with hundreds or thousands of tables where it would place an unrealistic constraint on naming conventions. Real world databases are commonly designed with <a href="/wiki/Foreign_key" title="Foreign key">foreign key</a> data that is not consistently populated (NULL values are allowed), due to business rules and context. It is common practice to modify column names of similar data in different tables and this lack of rigid consistency relegates natural joins to a theoretical concept for discussion. </p><p>The above sample query for inner joins can be expressed as a natural join in the following way: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="w"> </span><span class="k">NATURAL</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span><span class="p">;</span> </pre></div> <p>As with the explicit <code>USING</code> clause, only one DepartmentID column occurs in the joined table, with no qualifier: </p> <table class="wikitable" style="text-align:center"> <tbody><tr> <th>DepartmentID</th> <th>Employee.LastName</th> <th>Department.DepartmentName </th></tr> <tr> <td>34</td> <td>Smith</td> <td>Clerical </td></tr> <tr> <td>33</td> <td>Jones</td> <td>Engineering </td></tr> <tr> <td>34</td> <td>Robinson</td> <td>Clerical </td></tr> <tr> <td>33</td> <td>Heisenberg</td> <td>Engineering </td></tr> <tr> <td>31</td> <td>Rafferty</td> <td>Sales </td></tr></tbody></table> <p>PostgreSQL, MySQL and Oracle support natural joins; Microsoft T-SQL and IBM DB2 do not. The columns used in the join are implicit so the join code does not show which columns are expected, and a change in column names may change the results. In the <a href="/wiki/SQL:2011" title="SQL:2011">SQL:2011</a> standard, natural joins are part of the optional F401, "Extended joined table", package. </p><p>In many database environments the column names are controlled by an outside vendor, not the query developer. A natural join assumes stability and consistency in column names which can change during vendor mandated version upgrades. </p> <div class="mw-heading mw-heading2"><h2 id="Outer_join">Outer join</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=7" title="Edit section: Outer join"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The joined table retains each row—even if no other matching row exists. Outer joins subdivide further into left outer joins, right outer joins, and full outer joins, depending on which table's rows are retained: left, right, or both (in this case <i>left</i> and <i>right</i> refer to the two sides of the <code>JOIN</code> keyword). Like <a href="#Inner_join">inner joins</a>, one can further sub-categorize all types of outer joins as <a href="#Equi-join">equi-joins</a>, <a href="#Natural_join">natural joins</a>, <code><b>ON</b> <i>&lt;predicate&gt;</i></code> (<a href="/wiki/Relational_algebra#θ-join_and_equijoin" title="Relational algebra"><i>&#952;</i>-join</a>), etc.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">&#91;</span>8<span class="cite-bracket">&#93;</span></a></sup> </p><p>No implicit join-notation for outer joins exists in standard SQL. </p> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:SQL_Join_-_01_A_Left_Join_B.svg" class="mw-file-description"><img alt="A Venn diagram showing the left circle and overlapping portion filled." src="//upload.wikimedia.org/wikipedia/commons/thumb/f/f6/SQL_Join_-_01_A_Left_Join_B.svg/220px-SQL_Join_-_01_A_Left_Join_B.svg.png" decoding="async" width="220" height="149" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/f/f6/SQL_Join_-_01_A_Left_Join_B.svg/330px-SQL_Join_-_01_A_Left_Join_B.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/f/f6/SQL_Join_-_01_A_Left_Join_B.svg/440px-SQL_Join_-_01_A_Left_Join_B.svg.png 2x" data-file-width="234" data-file-height="158" /></a><figcaption>A Venn diagram representing the left join SQL statement between tables A and B.</figcaption></figure> <div class="mw-heading mw-heading3"><h3 id="Left_outer_join">Left outer join</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=8" title="Edit section: Left outer join"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The result of a <b>left outer join</b> (or simply <b>left join</b>) for tables A and B always contains all rows of the "left" table (A), even if the join-condition does not find any matching row in the "right" table (B). This means that if the <code>ON</code> clause matches 0 (zero) rows in B (for a given row in A), the join will still return a row in the result (for that row)—but with NULL in each column from B. A <b>left outer join</b> returns all the values from an inner join plus all values in the left table that do not match to the right table, including rows with NULL (empty) values in the link column. </p><p>For example, this allows us to find an employee's department, but still shows employees that have not been assigned to a department (contrary to the inner-join example above, where unassigned employees were excluded from the result). </p><p>Example of a left outer join (the <b><code>OUTER</code></b> keyword is optional), with the additional result row (compared with the inner join) italicized: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="w"> </span> <span class="k">LEFT</span><span class="w"> </span><span class="k">OUTER</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span><span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">;</span> </pre></div> <table class="wikitable" style="text-align:center"> <tbody><tr> <th>Employee.LastName</th> <th>Employee.DepartmentID</th> <th>Department.DepartmentName</th> <th>Department.DepartmentID </th></tr> <tr> <td>Jones</td> <td>33</td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Rafferty</td> <td>31</td> <td>Sales</td> <td>31 </td></tr> <tr> <td>Robinson</td> <td>34</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td>Smith</td> <td>34</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td><i>Williams</i></td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code> </td></tr> <tr> <td>Heisenberg</td> <td>33</td> <td>Engineering</td> <td>33 </td></tr></tbody></table> <div class="mw-heading mw-heading4"><h4 id="Alternative_syntaxes">Alternative syntaxes</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=9" title="Edit section: Alternative syntaxes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Oracle supports the deprecated<sup id="cite_ref-deprecated_plus_sign_9-0" class="reference"><a href="#cite_note-deprecated_plus_sign-9"><span class="cite-bracket">&#91;</span>9<span class="cite-bracket">&#93;</span></a></sup> syntax: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="p">,</span><span class="w"> </span><span class="n">department</span> <span class="k">WHERE</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">(</span><span class="o">+</span><span class="p">)</span> </pre></div> <p><a href="/wiki/Sybase" title="Sybase">Sybase</a> supports the syntax (<a href="/wiki/Microsoft_SQL_Server" title="Microsoft SQL Server">Microsoft SQL Server</a> deprecated this syntax since version 2000): </p> <div class="mw-highlight mw-highlight-lang-tsql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="p">,</span><span class="w"> </span><span class="n">department</span> <span class="k">WHERE</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">*=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span> </pre></div> <p><a href="/wiki/IBM_Informix" class="mw-redirect" title="IBM Informix">IBM Informix</a> supports the syntax: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="p">,</span><span class="w"> </span><span class="k">OUTER</span><span class="w"> </span><span class="n">department</span> <span class="k">WHERE</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span> </pre></div> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:SQL_Join_-_03_A_Right_Join_B.svg" class="mw-file-description"><img alt="A Venn diagram show the right circle and overlapping portions filled." src="//upload.wikimedia.org/wikipedia/commons/thumb/5/5f/SQL_Join_-_03_A_Right_Join_B.svg/220px-SQL_Join_-_03_A_Right_Join_B.svg.png" decoding="async" width="220" height="149" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/5/5f/SQL_Join_-_03_A_Right_Join_B.svg/330px-SQL_Join_-_03_A_Right_Join_B.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/5/5f/SQL_Join_-_03_A_Right_Join_B.svg/440px-SQL_Join_-_03_A_Right_Join_B.svg.png 2x" data-file-width="234" data-file-height="158" /></a><figcaption> A Venn diagram representing the right join SQL statement between tables A and B. </figcaption></figure> <div class="mw-heading mw-heading3"><h3 id="Right_outer_join">Right outer join</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=10" title="Edit section: Right outer join"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A <b>right outer join</b> (or <b>right join</b>) 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. </p><p>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. </p><p>Below is an example of a right outer join (the <b><code>OUTER</code></b> keyword is optional), with the additional result row italicized: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="w"> </span><span class="k">RIGHT</span><span class="w"> </span><span class="k">OUTER</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span> <span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">;</span> </pre></div> <table class="wikitable" style="text-align:center"> <tbody><tr> <th>Employee.LastName</th> <th>Employee.DepartmentID</th> <th>Department.DepartmentName</th> <th>Department.DepartmentID </th></tr> <tr> <td>Smith</td> <td>34</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td>Jones</td> <td>33</td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Robinson</td> <td>34</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td>Heisenberg</td> <td>33</td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Rafferty</td> <td>31</td> <td>Sales</td> <td>31 </td></tr> <tr> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td><i>Marketing</i></td> <td><i>35</i> </td></tr></tbody></table> <p>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. </p> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:SQL_Join_-_05b_A_Full_Join_B.svg" class="mw-file-description"><img alt="A Venn diagram showing the right circle, left circle, and overlapping portion filled." src="//upload.wikimedia.org/wikipedia/commons/thumb/3/3d/SQL_Join_-_05b_A_Full_Join_B.svg/220px-SQL_Join_-_05b_A_Full_Join_B.svg.png" decoding="async" width="220" height="149" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/3/3d/SQL_Join_-_05b_A_Full_Join_B.svg/330px-SQL_Join_-_05b_A_Full_Join_B.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/3/3d/SQL_Join_-_05b_A_Full_Join_B.svg/440px-SQL_Join_-_05b_A_Full_Join_B.svg.png 2x" data-file-width="234" data-file-height="158" /></a><figcaption>A Venn diagram representing the full join SQL statement between tables A and B.</figcaption></figure> <div class="mw-heading mw-heading3"><h3 id="Full_outer_join">Full outer join</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=11" title="Edit section: Full outer join"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Conceptually, a <b>full outer join</b> combines the effect of applying both left and right outer joins. Where rows in the full outer joined tables do not match, the result set will have NULL values for every column of the table that lacks a matching row. For those rows that do match, a single row will be produced in the result set (containing columns populated from both tables). </p><p>For example, this allows us to see each employee who is in a department and each department that has an employee, but also see each employee who is not part of a department and each department which doesn't have an employee. </p><p>Example of a full outer join (the <b><code>OUTER</code></b> keyword is optional): </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="k">OUTER</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span> <span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">;</span> </pre></div> <table class="wikitable" style="text-align:center"> <tbody><tr> <th>Employee.LastName</th> <th>Employee.DepartmentID</th> <th>Department.DepartmentName</th> <th>Department.DepartmentID </th></tr> <tr> <td>Smith</td> <td>34</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td>Jones</td> <td>33</td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Robinson</td> <td>34</td> <td>Clerical</td> <td>34 </td></tr> <tr> <td><i>Williams</i></td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code> </td></tr> <tr> <td>Heisenberg</td> <td>33</td> <td>Engineering</td> <td>33 </td></tr> <tr> <td>Rafferty</td> <td>31</td> <td>Sales</td> <td>31 </td></tr> <tr> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code></td> <td><i>Marketing</i></td> <td><i>35</i> </td></tr></tbody></table> <p>Some database systems do not support the full outer join functionality directly, but they can emulate it through the use of an inner join and UNION ALL selects of the "single table rows" from left and right tables respectively. The same example can appear as follows: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">LastName</span><span class="p">,</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">,</span> <span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentName</span><span class="p">,</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span> <span class="k">INNER</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span><span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span> <span class="k">UNION</span><span class="w"> </span><span class="k">ALL</span> <span class="k">SELECT</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">LastName</span><span class="p">,</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">,</span> <span class="w"> </span><span class="k">cast</span><span class="p">(</span><span class="k">NULL</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nb">varchar</span><span class="p">(</span><span class="mi">20</span><span class="p">)),</span><span class="w"> </span><span class="k">cast</span><span class="p">(</span><span class="k">NULL</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nb">integer</span><span class="p">)</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span> <span class="k">WHERE</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="p">(</span> <span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">department</span> <span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">)</span> <span class="k">UNION</span><span class="w"> </span><span class="k">ALL</span> <span class="k">SELECT</span><span class="w"> </span><span class="k">cast</span><span class="p">(</span><span class="k">NULL</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nb">varchar</span><span class="p">(</span><span class="mi">20</span><span class="p">)),</span><span class="w"> </span><span class="k">cast</span><span class="p">(</span><span class="k">NULL</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nb">integer</span><span class="p">),</span> <span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentName</span><span class="p">,</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span> <span class="k">FROM</span><span class="w"> </span><span class="n">department</span> <span class="k">WHERE</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="p">(</span> <span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">employee</span> <span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">)</span> </pre></div> <p>Another approach could be UNION ALL of left outer join and right outer join MINUS inner join. </p> <div class="mw-heading mw-heading2"><h2 id="Self-join">Self-join</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=12" title="Edit section: Self-join"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A self-join is joining a table to itself.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">&#91;</span>10<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="Example">Example</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=13" title="Edit section: Example"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>If there were two separate tables for employees and a query which requested employees in the first table having the same country as employees in the second table, a normal join operation could be used to find the answer table. However, all the employee information is contained within a single large table.<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">&#91;</span>11<span class="cite-bracket">&#93;</span></a></sup> </p><p>Consider a modified <code>Employee</code> table such as the following: </p> <table class="wikitable" style="text-align:center; float:left; margin-right:5px"> <caption>Employee Table </caption> <tbody><tr> <th>EmployeeID</th> <th>LastName</th> <th>Country</th> <th>DepartmentID </th></tr> <tr> <td>123</td> <td>Rafferty</td> <td>Australia</td> <td>31 </td></tr> <tr> <td>124</td> <td>Jones</td> <td>Australia</td> <td>33 </td></tr> <tr> <td>145</td> <td>Heisenberg</td> <td>Australia</td> <td>33 </td></tr> <tr> <td>201</td> <td>Robinson</td> <td>United States</td> <td>34 </td></tr> <tr> <td>305</td> <td>Smith</td> <td>Germany</td> <td>34 </td></tr> <tr> <td>306</td> <td>Williams</td> <td>Germany</td> <td><code style="color: white; background-color: gray; padding: 2px 4px; font-size: smaller;">NULL</code> </td></tr></tbody></table> <div style="clear:both;" class=""></div> <p>An example solution query could be as follows: </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">F</span><span class="p">.</span><span class="n">EmployeeID</span><span class="p">,</span><span class="w"> </span><span class="n">F</span><span class="p">.</span><span class="n">LastName</span><span class="p">,</span><span class="w"> </span><span class="n">S</span><span class="p">.</span><span class="n">EmployeeID</span><span class="p">,</span><span class="w"> </span><span class="n">S</span><span class="p">.</span><span class="n">LastName</span><span class="p">,</span><span class="w"> </span><span class="n">F</span><span class="p">.</span><span class="n">Country</span> <span class="k">FROM</span><span class="w"> </span><span class="n">Employee</span><span class="w"> </span><span class="n">F</span><span class="w"> </span><span class="k">INNER</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">Employee</span><span class="w"> </span><span class="n">S</span><span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="n">F</span><span class="p">.</span><span class="n">Country</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">S</span><span class="p">.</span><span class="n">Country</span> <span class="k">WHERE</span><span class="w"> </span><span class="n">F</span><span class="p">.</span><span class="n">EmployeeID</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">S</span><span class="p">.</span><span class="n">EmployeeID</span> <span class="k">ORDER</span><span class="w"> </span><span class="k">BY</span><span class="w"> </span><span class="n">F</span><span class="p">.</span><span class="n">EmployeeID</span><span class="p">,</span><span class="w"> </span><span class="n">S</span><span class="p">.</span><span class="n">EmployeeID</span><span class="p">;</span> </pre></div> <p>Which results in the following table being generated. </p> <table class="wikitable" style="text-align:center; float:left; margin-right:5px"> <caption>Employee Table after Self-join by Country </caption> <tbody><tr> <th>EmployeeID</th> <th>LastName</th> <th>EmployeeID</th> <th>LastName</th> <th>Country </th></tr> <tr> <td>123</td> <td>Rafferty</td> <td>124</td> <td>Jones</td> <td>Australia </td></tr> <tr> <td>123</td> <td>Rafferty</td> <td>145</td> <td>Heisenberg</td> <td>Australia </td></tr> <tr> <td>124</td> <td>Jones</td> <td>145</td> <td>Heisenberg</td> <td>Australia </td></tr> <tr> <td>305</td> <td>Smith</td> <td>306</td> <td>Williams</td> <td>Germany </td></tr></tbody></table> <div style="clear:both;" class=""></div> <p>For this example: </p> <ul><li><code>F</code> and <code>S</code> are <a href="/wiki/Alias_(SQL)" title="Alias (SQL)">aliases</a> for the first and second copies of the employee table.</li> <li>The condition <code>F.Country = S.Country</code> excludes pairings between employees in different countries. The example question only wanted pairs of employees in the same country.</li> <li>The condition <code>F.EmployeeID &lt; S.EmployeeID</code> excludes pairings where the <code>EmployeeID</code> of the first employee is greater than or equal to the <code>EmployeeID</code> of the second employee. In other words, the effect of this condition is to exclude duplicate pairings and self-pairings. Without it, the following less useful table would be generated (the table below displays only the "Germany" portion of the result):</li></ul> <table class="wikitable" style="text-align:center; float:left; margin-right:5px"> <tbody><tr> <th>EmployeeID</th> <th>LastName</th> <th>EmployeeID</th> <th>LastName</th> <th>Country </th></tr> <tr> <td>305</td> <td>Smith</td> <td>305</td> <td>Smith</td> <td>Germany </td></tr> <tr> <td>305</td> <td>Smith</td> <td>306</td> <td>Williams</td> <td>Germany </td></tr> <tr> <td>306</td> <td>Williams</td> <td>305</td> <td>Smith</td> <td>Germany </td></tr> <tr> <td>306</td> <td>Williams</td> <td>306</td> <td>Williams</td> <td>Germany </td></tr></tbody></table> <div style="clear:both;" class=""></div> <p>Only one of the two middle pairings is needed to satisfy the original question, and the topmost and bottommost are of no interest at all in this example. </p> <div class="mw-heading mw-heading2"><h2 id="Alternatives">Alternatives</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=14" title="Edit section: Alternatives"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The effect of an outer join can also be obtained using a UNION ALL between an INNER JOIN and a SELECT of the rows in the "main" table that do not fulfill the join condition. For example, </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">LastName</span><span class="p">,</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">,</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentName</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span> <span class="k">LEFT</span><span class="w"> </span><span class="k">OUTER</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span><span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">;</span> </pre></div> <p>can also be written as </p> <div class="mw-highlight mw-highlight-lang-sql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">LastName</span><span class="p">,</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">,</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentName</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span> <span class="k">INNER</span><span class="w"> </span><span class="k">JOIN</span><span class="w"> </span><span class="n">department</span><span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span> <span class="k">UNION</span><span class="w"> </span><span class="k">ALL</span> <span class="k">SELECT</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">LastName</span><span class="p">,</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">,</span><span class="w"> </span><span class="k">cast</span><span class="p">(</span><span class="k">NULL</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nb">varchar</span><span class="p">(</span><span class="mi">20</span><span class="p">))</span> <span class="k">FROM</span><span class="w"> </span><span class="n">employee</span> <span class="k">WHERE</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="p">(</span> <span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">department</span> <span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">employee</span><span class="p">.</span><span class="n">DepartmentID</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">department</span><span class="p">.</span><span class="n">DepartmentID</span><span class="p">)</span> </pre></div> <div class="mw-heading mw-heading2"><h2 id="Implementation">Implementation</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=15" title="Edit section: Implementation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1273380762/mw-parser-output/.tmulti">.mw-parser-output .tmulti .multiimageinner{display:flex;flex-direction:column}.mw-parser-output .tmulti .trow{display:flex;flex-direction:row;clear:left;flex-wrap:wrap;width:100%;box-sizing:border-box}.mw-parser-output .tmulti .tsingle{margin:1px;float:left}.mw-parser-output .tmulti .theader{clear:both;font-weight:bold;text-align:center;align-self:center;background-color:transparent;width:100%}.mw-parser-output .tmulti .thumbcaption{background-color:transparent}.mw-parser-output .tmulti .text-align-left{text-align:left}.mw-parser-output .tmulti .text-align-right{text-align:right}.mw-parser-output .tmulti .text-align-center{text-align:center}@media all and (max-width:720px){.mw-parser-output .tmulti .thumbinner{width:100%!important;box-sizing:border-box;max-width:none!important;align-items:center}.mw-parser-output .tmulti .trow{justify-content:center}.mw-parser-output .tmulti .tsingle{float:none!important;max-width:100%!important;box-sizing:border-box;text-align:center}.mw-parser-output .tmulti .tsingle .thumbcaption{text-align:left}.mw-parser-output .tmulti .trow>.thumbcaption{text-align:center}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .tmulti .multiimageinner span:not(.skin-invert-image):not(.skin-invert):not(.bg-transparent) img{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .tmulti .multiimageinner span:not(.skin-invert-image):not(.skin-invert):not(.bg-transparent) img{background-color:white}}</style><div class="thumb tmulti tright"><div class="thumbinner multiimageinner" style="width:288px;max-width:288px"><div class="trow"><div class="tsingle" style="width:142px;max-width:142px"><div class="thumbimage"><span typeof="mw:File"><a href="/wiki/File:Triangle-query-join-query-plan-r-st.svg" class="mw-file-description"><img alt="A query plan for the triangle query R(A, B) ⋈ S(B, C) ⋈ T(A, C) that uses binary joins. It joins S and T first, then joins the result with R." src="//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Triangle-query-join-query-plan-r-st.svg/140px-Triangle-query-join-query-plan-r-st.svg.png" decoding="async" width="140" height="154" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Triangle-query-join-query-plan-r-st.svg/210px-Triangle-query-join-query-plan-r-st.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/8/80/Triangle-query-join-query-plan-r-st.svg/280px-Triangle-query-join-query-plan-r-st.svg.png 2x" data-file-width="213" data-file-height="235" /></a></span></div></div><div class="tsingle" style="width:142px;max-width:142px"><div class="thumbimage"><span typeof="mw:File"><a href="/wiki/File:Triangle-query-join-query-plan-rs-t.svg" class="mw-file-description"><img alt="A query plan for the triangle query R(A, B) ⋈ S(B, C) ⋈ T(A, C) that uses binary joins. It joins R and S first, then joins the result with T." src="//upload.wikimedia.org/wikipedia/commons/thumb/1/18/Triangle-query-join-query-plan-rs-t.svg/140px-Triangle-query-join-query-plan-rs-t.svg.png" decoding="async" width="140" height="154" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/1/18/Triangle-query-join-query-plan-rs-t.svg/210px-Triangle-query-join-query-plan-rs-t.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/1/18/Triangle-query-join-query-plan-rs-t.svg/280px-Triangle-query-join-query-plan-rs-t.svg.png 2x" data-file-width="213" data-file-height="235" /></a></span></div></div></div><div class="trow" style="display:flex"><div class="thumbcaption">Two possible <a href="/wiki/Query_plan" title="Query plan">query plans</a> for the <i><dfn>triangle query</dfn></i> <span class="texhtml">R(A, B) ⋈ S(B, C) ⋈ T(A, C)</span>; the first joins <span class="texhtml mvar" style="font-style:italic;">S</span> and <span class="texhtml mvar" style="font-style:italic;">T</span> first and joins the result with <span class="texhtml mvar" style="font-style:italic;">R</span>, the second joins <span class="texhtml mvar" style="font-style:italic;">R</span> and <span class="texhtml mvar" style="font-style:italic;">S</span> first and joins the result with <span class="texhtml mvar" style="font-style:italic;">T</span></div></div></div></div> <p>Much work in database-systems has aimed at efficient implementation of joins, because relational systems commonly call for joins, yet face difficulties in optimising their efficient execution. The problem arises because inner joins operate both <a href="/wiki/Commutative" class="mw-redirect" title="Commutative">commutatively</a> and <a href="/wiki/Associative" class="mw-redirect" title="Associative">associatively</a>. In practice, this means that the user merely supplies the list of tables for joining and the join conditions to use, and the database system has the task of determining the most efficient way to perform the operation. The choices become more complex as the number of tables involved in a query increases, with each table having different characteristics in record count, average record length (considering NULL fields) and available indexes. Where Clause filters can also significantly impact query volume and cost. </p><p>A <a href="/wiki/Query_optimizer" class="mw-redirect" title="Query optimizer">query optimizer</a> determines how to execute a query containing joins. A query optimizer has two basic freedoms: </p> <ol><li><b>Join order</b>: Because it joins functions commutatively and associatively, the order in which the system joins tables does not change the final result set of the query. However, join-order <b>could</b> have an enormous impact on the cost of the join operation, so choosing the best join order becomes very important.</li> <li><b>Join method</b>: Given two tables and a join condition, multiple <a href="/wiki/Algorithm" title="Algorithm">algorithms</a> can produce the result set of the join. Which algorithm runs most efficiently depends on the sizes of the input tables, the number of rows from each table that match the join condition, and the operations required by the rest of the query.</li></ol> <p>Many join-algorithms treat their inputs differently. One can refer to the inputs to a join as the "outer" and "inner" join operands, or "left" and "right", respectively. In the case of nested loops, for example, the database system will scan the entire inner relation for each row of the outer relation. </p><p>One can classify query-plans involving joins as follows:<sup id="cite_ref-Yu1998_12-0" class="reference"><a href="#cite_note-Yu1998-12"><span class="cite-bracket">&#91;</span>12<span class="cite-bracket">&#93;</span></a></sup> </p> <dl><dt>left-deep</dt> <dd>using a base table (rather than another join) as the inner operand of each join in the plan</dd> <dt>right-deep</dt> <dd>using a base table as the outer operand of each join in the plan</dd> <dt>bushy</dt> <dd>neither left-deep nor right-deep; both inputs to a join may themselves result from joins</dd></dl> <p>These names derive from the appearance of the <a href="/wiki/Query_plan" title="Query plan">query plan</a> if drawn as a <a href="/wiki/Tree_data_structure" class="mw-redirect" title="Tree data structure">tree</a>, with the outer join relation on the left and the inner relation on the right (as convention dictates). </p> <div class="mw-heading mw-heading3"><h3 id="Join_algorithms">Join algorithms</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=16" title="Edit section: Join algorithms"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Comparison_of_join_algorithms.png" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Comparison_of_join_algorithms.png/220px-Comparison_of_join_algorithms.png" decoding="async" width="220" height="130" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Comparison_of_join_algorithms.png/330px-Comparison_of_join_algorithms.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Comparison_of_join_algorithms.png/440px-Comparison_of_join_algorithms.png 2x" data-file-width="1955" data-file-height="1155" /></a><figcaption>An illustration of properties of join algorithms. When performing a join between more than two relations on more than two attributes, binary join algorithms such as <a href="/wiki/Hash_join" title="Hash join">hash join</a> operate over two relations at a time, and join them on all attributes in the join condition; <a href="/wiki/Worst-case_optimal_join_algorithm" title="Worst-case optimal join algorithm">worst-case optimal algorithms</a> such as generic join operate on a single attribute at a time but join all the relations on this attribute.<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">&#91;</span>13<span class="cite-bracket">&#93;</span></a></sup></figcaption></figure> <p>Three fundamental algorithms for performing a binary join operation exist: <a href="/wiki/Nested_loop_join" title="Nested loop join">nested loop join</a>, <a href="/wiki/Sort-merge_join" title="Sort-merge join">sort-merge join</a> and <a href="/wiki/Hash_join" title="Hash join">hash join</a>. <a href="/wiki/Worst-case_optimal_join_algorithm" title="Worst-case optimal join algorithm">Worst-case optimal join algorithms</a> are asymptotically faster than binary join algorithms for joins between more than two relations in the <a href="/wiki/Worst_case" class="mw-redirect" title="Worst case">worst case</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Join_indexes">Join indexes</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=17" title="Edit section: Join indexes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Join indexes are <a href="/wiki/Database_index" title="Database index">database indexes</a> that facilitate the processing of join queries in <a href="/wiki/Data_warehouse" title="Data warehouse">data warehouses</a>: they are currently (2012) available in implementations by <a href="/wiki/Oracle_database" class="mw-redirect" title="Oracle database">Oracle</a><sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">&#91;</span>14<span class="cite-bracket">&#93;</span></a></sup> and <a href="/wiki/Teradata" title="Teradata">Teradata</a>.<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">&#91;</span>15<span class="cite-bracket">&#93;</span></a></sup> </p><p>In the Teradata implementation, specified columns, aggregate functions on columns, or components of date columns from one or more tables are specified using a syntax similar to the definition of a <a href="/wiki/Database_view" class="mw-redirect" title="Database view">database view</a>: up to 64 columns/column expressions can be specified in a single join index. Optionally, a column that defines the <a href="/wiki/Primary_key" title="Primary key">primary key</a> of the composite data may also be specified: on parallel hardware, the column values are used to partition the index's contents across multiple disks. When the source tables are updated interactively by users, the contents of the join index are automatically updated. Any query whose WHERE clause specifies any combination of columns or column expressions that are an exact subset of those defined in a join index (a so-called "covering query") will cause the join index, rather than the original tables and their indexes, to be consulted during query execution. </p><p>The Oracle implementation limits itself to using <a href="/wiki/Bitmap_index" title="Bitmap index">bitmap indexes</a>. A <i>bitmap join index</i> is used for low-cardinality columns (i.e., columns containing fewer than 300 distinct values, according to the Oracle documentation): it combines low-cardinality columns from multiple related tables. The example Oracle uses is that of an inventory system, where different suppliers provide different parts. The <a href="/wiki/Database_schema" title="Database schema">schema</a> has three linked tables: two "master tables", Part and Supplier, and a "detail table", Inventory. The last is a many-to-many table linking Supplier to Part, and contains the most rows. Every part has a Part Type, and every supplier is based in the US, and has a State column. There are not more than 60 states+territories in the US, and not more than 300 Part Types. The bitmap join index is defined using a standard three-table join on the three tables above, and specifying the Part_Type and Supplier_State columns for the index. However, it is defined on the Inventory table, even though the columns Part_Type and Supplier_State are "borrowed" from Supplier and Part respectively. </p><p>As for Teradata, an Oracle bitmap join index is only utilized to answer a query when the query's WHERE clause specifies columns limited to those that are included in the join index. </p> <div class="mw-heading mw-heading3"><h3 id="Straight_join">Straight join</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=18" title="Edit section: Straight join"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Some database systems allow the user to force the system to read the tables in a join in a particular order. This is used when the join optimizer chooses to read the tables in an inefficient order. For example, in <a href="/wiki/MySQL" title="MySQL">MySQL</a> the command <code>STRAIGHT_JOIN</code> reads the tables in exactly the order listed in the query.<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">&#91;</span>16<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=19" title="Edit section: See also"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a href="/wiki/Join_(relational_algebra)" class="mw-redirect" title="Join (relational algebra)">Join (relational algebra)</a></li> <li><a href="/wiki/Antijoin" class="mw-redirect" title="Antijoin">Antijoin</a></li> <li><a href="/wiki/Set_operations_(SQL)" title="Set operations (SQL)">Set operations (SQL)</a></li></ul> <div class="mw-heading mw-heading2"><h2 id="References">References</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=20" title="Edit section: References"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="Citations">Citations</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=21" title="Edit section: Citations"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1239543626">.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}</style><div class="reflist"> <div class="mw-references-wrap mw-references-columns"><ol class="references"> <li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://www.sqlguides.com/sql_cross_join.php">SQL CROSS JOIN</a></span> </li> <li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text">Greg Robidoux, "Avoid SQL Server functions in the WHERE clause for Performance", MSSQL Tips, 3 May 2007</span> </li> <li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text">Patrick Wolf, "Inside Oracle APEX "Caution when using PL/SQL functions in a SQL statement", 30 November 2006</span> </li> <li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text">Gregory A. Larsen, "T-SQL Best Practices - Don't Use Scalar Value Functions in Column List or WHERE Clauses", 29 October 2009,</span> </li> <li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://www.java2s.com/Tutorial/Oracle/0140__Table-Joins/SimplifyingJoinswiththeUSINGKeyword.htm">Simplifying Joins with the USING Keyword</a></span> </li> <li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text">In <a href="/wiki/Unicode" title="Unicode">Unicode</a>, the bowtie symbol is ⋈ (U+22C8).</span> </li> <li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:13430766143199">Ask Tom "Oracle support of ANSI joins."</a> <a rel="nofollow" class="external text" href="http://awads.net/wp/2006/03/20/back-to-basics-inner-joins/#comment-2837">Back to basics: inner joins&#160;» Eddie Awad's Blog</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20101119182541/http://awads.net/wp/2006/03/20/back-to-basics-inner-joins/#comment-2837">Archived</a> 2010-11-19 at the <a href="/wiki/Wayback_Machine" title="Wayback Machine">Wayback Machine</a></span> </li> <li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}</style><cite id="CITEREFSilberschatzKorthSudarshan2002" class="citation book cs1"><a href="/wiki/Abraham_Silberschatz" title="Abraham Silberschatz">Silberschatz, Abraham</a>; <a href="/wiki/Henry_F._Korth" title="Henry F. Korth">Korth, Hank</a>; Sudarshan, S. (2002). "Section 4.10.2: Join Types and Conditions". <i>Database System Concepts</i> (4th&#160;ed.). McGraw-Hill. p.&#160;166. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/0072283637" title="Special:BookSources/0072283637"><bdi>0072283637</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=Section+4.10.2%3A+Join+Types+and+Conditions&amp;rft.btitle=Database+System+Concepts&amp;rft.pages=166&amp;rft.edition=4th&amp;rft.pub=McGraw-Hill&amp;rft.date=2002&amp;rft.isbn=0072283637&amp;rft.aulast=Silberschatz&amp;rft.aufirst=Abraham&amp;rft.au=Korth%2C+Hank&amp;rft.au=Sudarshan%2C+S.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AJoin+%28SQL%29" class="Z3988"></span></span> </li> <li id="cite_note-deprecated_plus_sign-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-deprecated_plus_sign_9-0">^</a></b></span> <span class="reference-text"> <a rel="nofollow" class="external text" href="http://www.dba-oracle.com/tips_oracle_left_outer_join.htm">Oracle Left Outer Join</a></span> </li> <li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><a href="#CITEREFShah2005">Shah 2005</a>, p.&#160;165</span> </li> <li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text">Adapted from <a href="#CITEREFPratt2005">Pratt 2005</a>, pp.&#160;115–6</span> </li> <li id="cite_note-Yu1998-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-Yu1998_12-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFYuMeng1998">Yu &amp; Meng 1998</a>, p.&#160;213</span> </li> <li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFWangWillseySuciu2023" class="citation arxiv cs1">Wang, Yisu Remy; Willsey, Max; Suciu, Dan (2023-01-27). "Free Join: Unifying Worst-Case Optimal and Traditional Joins". <a href="/wiki/ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/2301.10841">2301.10841</a></span> [<a rel="nofollow" class="external text" href="https://arxiv.org/archive/cs.DB">cs.DB</a>].</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=preprint&amp;rft.jtitle=arXiv&amp;rft.atitle=Free+Join%3A+Unifying+Worst-Case+Optimal+and+Traditional+Joins&amp;rft.date=2023-01-27&amp;rft_id=info%3Aarxiv%2F2301.10841&amp;rft.aulast=Wang&amp;rft.aufirst=Yisu+Remy&amp;rft.au=Willsey%2C+Max&amp;rft.au=Suciu%2C+Dan&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AJoin+%28SQL%29" class="Z3988"></span></span> </li> <li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text">Oracle Bitmap Join Indexes. <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/database/oracle/oracle-database/23/cncpt/indexes-and-index-organized-tables.html#GUID-3286EBA4-0D5B-423D-815B-997A3E4B4B6C">"Database Concepts - 5 Indexes and Index-Organized Tables - Bitmap Join Indexes"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2024-06-23</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Database+Concepts+-+5+Indexes+and+Index-Organized+Tables+-+Bitmap+Join+Indexes&amp;rft_id=https%3A%2F%2Fdocs.oracle.com%2Fen%2Fdatabase%2Foracle%2Foracle-database%2F23%2Fcncpt%2Findexes-and-index-organized-tables.html%23GUID-3286EBA4-0D5B-423D-815B-997A3E4B4B6C&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AJoin+%28SQL%29" class="Z3988"></span></span> </li> <li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text">Teradata Join Indexes. <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Definition-Language-Syntax-and-Examples/Index-Statements/CREATE-JOIN-INDEX">"SQL Data Definition Language Syntax and Examples - CREATE JOIN INDEX"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2024-06-23</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=SQL+Data+Definition+Language+Syntax+and+Examples+-+CREATE+JOIN+INDEX&amp;rft_id=https%3A%2F%2Fdocs.teradata.com%2Fr%2FEnterprise_IntelliFlex_VMware%2FSQL-Data-Definition-Language-Syntax-and-Examples%2FIndex-Statements%2FCREATE-JOIN-INDEX&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AJoin+%28SQL%29" class="Z3988"></span></span> </li> <li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://dev.mysql.com/doc/refman/5.7/en/join.html">"13.2.9.2 JOIN Syntax"</a>. <i>MySQL 5.7 Reference Manual</i>. <a href="/wiki/Oracle_Corporation" title="Oracle Corporation">Oracle Corporation</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2015-12-03</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=MySQL+5.7+Reference+Manual&amp;rft.atitle=13.2.9.2+JOIN+Syntax&amp;rft_id=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Fjoin.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AJoin+%28SQL%29" class="Z3988"></span></span> </li> </ol></div></div> <div class="mw-heading mw-heading3"><h3 id="Sources">Sources</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=22" title="Edit section: Sources"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1239549316">.mw-parser-output .refbegin{margin-bottom:0.5em}.mw-parser-output .refbegin-hanging-indents>ul{margin-left:0}.mw-parser-output .refbegin-hanging-indents>ul>li{margin-left:0;padding-left:3.2em;text-indent:-3.2em}.mw-parser-output .refbegin-hanging-indents ul,.mw-parser-output .refbegin-hanging-indents ul li{list-style:none}@media(max-width:720px){.mw-parser-output .refbegin-hanging-indents>ul>li{padding-left:1.6em;text-indent:-1.6em}}.mw-parser-output .refbegin-columns{margin-top:0.3em}.mw-parser-output .refbegin-columns ul{margin-top:0}.mw-parser-output .refbegin-columns li{page-break-inside:avoid;break-inside:avoid-column}@media screen{.mw-parser-output .refbegin{font-size:90%}}</style><div class="refbegin" style=""> <ul><li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFPratt2005" class="citation cs2">Pratt, Phillip J (2005), <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/guidetosql00prat"><i>A Guide To SQL, Seventh Edition</i></a></span>, Thomson Course Technology, <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-619-21674-0" title="Special:BookSources/978-0-619-21674-0"><bdi>978-0-619-21674-0</bdi></a></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=A+Guide+To+SQL%2C+Seventh+Edition&amp;rft.pub=Thomson+Course+Technology&amp;rft.date=2005&amp;rft.isbn=978-0-619-21674-0&amp;rft.aulast=Pratt&amp;rft.aufirst=Phillip+J&amp;rft_id=https%3A%2F%2Farchive.org%2Fdetails%2Fguidetosql00prat&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AJoin+%28SQL%29" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFShah2005" class="citation cs2">Shah, Nilesh (2005) [2002], <i>Database Systems Using Oracle – A Simplified Guide to SQL and PL/SQL Second Edition</i> (International&#160;ed.), Pearson Education International, <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/0-13-191180-5" title="Special:BookSources/0-13-191180-5"><bdi>0-13-191180-5</bdi></a></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Database+Systems+Using+Oracle+%E2%80%93+A+Simplified+Guide+to+SQL+and+PL%2FSQL+Second+Edition&amp;rft.edition=International&amp;rft.pub=Pearson+Education+International&amp;rft.date=2005&amp;rft.isbn=0-13-191180-5&amp;rft.aulast=Shah&amp;rft.aufirst=Nilesh&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AJoin+%28SQL%29" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFYuMeng1998" class="citation cs2">Yu, Clement T.; Meng, Weiyi (1998), <a rel="nofollow" class="external text" href="https://books.google.com/books?id=aBHRDhrrehYC"><i>Principles of Database Query Processing for Advanced Applications</i></a>, Morgan Kaufmann, <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-1-55860-434-6" title="Special:BookSources/978-1-55860-434-6"><bdi>978-1-55860-434-6</bdi></a><span class="reference-accessdate">, retrieved <span class="nowrap">2009-03-03</span></span></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Principles+of+Database+Query+Processing+for+Advanced+Applications&amp;rft.pub=Morgan+Kaufmann&amp;rft.date=1998&amp;rft.isbn=978-1-55860-434-6&amp;rft.aulast=Yu&amp;rft.aufirst=Clement+T.&amp;rft.au=Meng%2C+Weiyi&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DaBHRDhrrehYC&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AJoin+%28SQL%29" class="Z3988"></span></li></ul> </div> <div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Join_(SQL)&amp;action=edit&amp;section=23" title="Edit section: External links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li>Specific to products: <ul><li><a rel="nofollow" class="external text" href="http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.sqlug/html/sqlug/sqlug138.htm">Sybase ASE 15 Joins</a></li> <li><a rel="nofollow" class="external text" href="http://dev.mysql.com/doc/refman/8.0/en/join.html">MySQL 8.0 Joins</a></li> <li><a rel="nofollow" class="external text" href="https://www.postgresql.org/docs/14/tutorial-join.html">PostgreSQL 14 Joins</a></li> <li><a rel="nofollow" class="external text" href="https://docs.microsoft.com/en-us/sql/relational-databases/performance/joins?view=sql-server-ver15">Joins in Microsoft SQL Server</a></li> <li><a rel="nofollow" class="external text" href="http://maxdb.sap.com/currentdoc/45/f31c38e95511d5995d00508b5d5211/content.htm">Joins in MaxDB 7.6</a></li> <li><a rel="nofollow" class="external text" href="http://docs.oracle.com/cd/E16655_01/server.121/e17209/queries006.htm">Joins in Oracle 12c R1</a></li> <li><a rel="nofollow" class="external text" href="https://oracletutorial.net/oracle-sql-joins.html">Oracle SQL Joins</a></li></ul></li></ul> <div style="clear:both;" class=""></div> <div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}</style><style data-mw-deduplicate="TemplateStyles:r1236075235">.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}</style><style data-mw-deduplicate="TemplateStyles:r920966791">.mw-parser-output span.smallcaps{font-variant:small-caps}.mw-parser-output span.smallcaps-smaller{font-size:85%}</style><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r920966791" /></div><div role="navigation" class="navbox" aria-labelledby="SQL70" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374" /><style data-mw-deduplicate="TemplateStyles:r1239400231">.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}</style><div class="navbar plainlinks hlist navbar-mini"><ul><li class="nv-view"><a href="/wiki/Template:SQL" title="Template:SQL"><abbr title="View this template">v</abbr></a></li><li class="nv-talk"><a href="/wiki/Template_talk:SQL" title="Template talk:SQL"><abbr title="Discuss this template">t</abbr></a></li><li class="nv-edit"><a href="/wiki/Special:EditPage/Template:SQL" title="Special:EditPage/Template:SQL"><abbr title="Edit this template">e</abbr></a></li></ul></div><div id="SQL70" style="font-size:114%;margin:0 4em"><a href="/wiki/SQL" title="SQL">SQL</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">Versions</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/SEQUEL" class="mw-redirect" title="SEQUEL">SEQUEL</a></li> <li><a href="/w/index.php?title=SQL-86&amp;action=edit&amp;redlink=1" class="new" title="SQL-86 (page does not exist)">SQL-86</a></li> <li><a href="/w/index.php?title=SQL-89&amp;action=edit&amp;redlink=1" class="new" title="SQL-89 (page does not exist)">SQL-89</a></li> <li><a href="/wiki/SQL-92" title="SQL-92">SQL-92</a></li> <li><a href="/wiki/SQL:1999" title="SQL:1999">SQL:1999</a></li> <li><a href="/wiki/SQL:2003" title="SQL:2003">SQL:2003</a></li> <li><a href="/wiki/SQL:2006" title="SQL:2006">SQL:2006</a></li> <li><a href="/wiki/SQL:2008" title="SQL:2008">SQL:2008</a></li> <li><a href="/wiki/SQL:2011" title="SQL:2011">SQL:2011</a></li> <li><a href="/wiki/SQL:2016" title="SQL:2016">SQL:2016</a></li> <li><a href="/wiki/SQL:2023" title="SQL:2023">SQL:2023</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/SQL_reserved_words" class="mw-redirect" title="SQL reserved words">Keywords</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><span class="smallcaps"><a href="/wiki/Alias_(SQL)" title="Alias (SQL)">As</a></span></li> <li><span class="smallcaps"><a href="/wiki/Case_(SQL)" class="mw-redirect" title="Case (SQL)">Case</a></span></li> <li><span class="smallcaps"><a href="/wiki/Create_(SQL)" class="mw-redirect" title="Create (SQL)">Create</a></span></li> <li><span class="smallcaps"><a href="/wiki/Delete_(SQL)" title="Delete (SQL)">Delete</a></span></li> <li><span class="smallcaps"><a href="/wiki/From_(SQL)" title="From (SQL)">From</a></span></li> <li><span class="smallcaps"><a href="/wiki/Group_by_(SQL)" title="Group by (SQL)">Group by</a></span></li> <li><span class="smallcaps"><a href="/wiki/Having_(SQL)" title="Having (SQL)">Having</a></span></li> <li><span class="smallcaps"><a href="/wiki/Insert_(SQL)" title="Insert (SQL)">Insert</a></span></li> <li><span class="smallcaps"><a class="mw-selflink selflink">Join</a></span></li> <li><span class="smallcaps"><a href="/wiki/Merge_(SQL)" title="Merge (SQL)">Merge</a></span></li> <li><span class="smallcaps"><a href="/wiki/Null_(SQL)" title="Null (SQL)">Null</a></span></li> <li><span class="smallcaps"><a href="/wiki/Order_by" title="Order by">Order by</a></span></li> <li><span class="smallcaps"><a href="/wiki/Window_function_(SQL)" title="Window function (SQL)">Over</a></span></li> <li><span class="smallcaps"><a href="/wiki/Prepare_(SQL)" class="mw-redirect" title="Prepare (SQL)">Prepare</a></span></li> <li><span class="smallcaps"><a href="/wiki/Select_(SQL)" title="Select (SQL)">Select</a></span></li> <li><span class="smallcaps"><a href="/wiki/Truncate_(SQL)" title="Truncate (SQL)">Truncate</a></span></li> <li><span class="smallcaps"><a href="/wiki/Set_operations_(SQL)" title="Set operations (SQL)">Union</a></span></li> <li><span class="smallcaps"><a href="/wiki/Update_(SQL)" title="Update (SQL)">Update</a></span></li> <li><span class="smallcaps"><a href="/wiki/With_(SQL)" class="mw-redirect" title="With (SQL)">With</a></span></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Related</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Edgar_F._Codd" title="Edgar F. Codd">Edgar Codd</a></li> <li><a href="/wiki/Relational_database" title="Relational database">Relational database</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">ISO/IEC SQL parts</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/w/index.php?title=SQL/Framework&amp;action=edit&amp;redlink=1" class="new" title="SQL/Framework (page does not exist)">Framework</a></li> <li><a href="/w/index.php?title=SQL/Foundation&amp;action=edit&amp;redlink=1" class="new" title="SQL/Foundation (page does not exist)">Foundation</a></li> <li><a href="/wiki/SQL/CLI" class="mw-redirect" title="SQL/CLI">Call-Level Interface</a></li> <li><a href="/wiki/SQL/PSM" title="SQL/PSM">Persistent Stored Modules</a></li> <li><a href="/wiki/SQL/MED" title="SQL/MED">Management of External Data</a></li> <li><a href="/wiki/SQL/OLB" title="SQL/OLB">Object Language Bindings</a></li> <li><a href="/wiki/SQL/Schemata" title="SQL/Schemata">Information and Definition Schemas</a></li> <li><a href="/wiki/SQL/JRT" title="SQL/JRT">SQL Routines and Types for the Java Programming Language</a></li> <li><a href="/wiki/SQL/XML" title="SQL/XML">XML-Related Specifications</a></li></ul> </div></td></tr></tbody></table></div> <!-- NewPP limit report Parsed by mw‐web.codfw.next‐88cd69d45‐6r8xn Cached time: 20250305213045 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.445 seconds Real time usage: 0.615 seconds Preprocessor visited node count: 2033/1000000 Post‐expand include size: 44846/2097152 bytes Template argument size: 3677/2097152 bytes Highest expansion depth: 12/100 Expensive parser function count: 23/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 71161/5000000 bytes Lua time usage: 0.217/10.000 seconds Lua memory usage: 7635814/52428800 bytes Number of Wikibase entities loaded: 0/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 428.884 1 -total 32.22% 138.178 1 Template:Reflist 20.02% 85.876 1 Template:SQL 19.00% 81.493 1 Template:Navbox 18.43% 79.061 1 Template:Short_description 16.75% 71.856 1 Template:Cite_book 11.05% 47.398 2 Template:Pagetype 7.37% 31.624 2 Template:Fix 7.35% 31.520 1 Template:Why 6.59% 28.273 1 Template:Multiple_image --> <!-- Saved in parser cache with key enwiki:pcache:665204:|#|:idhash:canonical and timestamp 20250305213045 and revision id 1274538111. Rendering was triggered because: page-view --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?useformat=desktop&amp;type=1x1&amp;usesul3=0" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://en.wikipedia.org/w/index.php?title=Join_(SQL)&amp;oldid=1274538111">https://en.wikipedia.org/w/index.php?title=Join_(SQL)&amp;oldid=1274538111</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Help:Category" title="Help:Category">Category</a>: <ul><li><a href="/wiki/Category:SQL_keywords" title="Category:SQL keywords">SQL keywords</a></li></ul></div><div id="mw-hidden-catlinks" class="mw-hidden-catlinks mw-hidden-cats-hidden">Hidden categories: <ul><li><a href="/wiki/Category:Webarchive_template_wayback_links" title="Category:Webarchive template wayback links">Webarchive template wayback links</a></li><li><a href="/wiki/Category:Articles_with_short_description" title="Category:Articles with short description">Articles with short description</a></li><li><a href="/wiki/Category:Short_description_matches_Wikidata" title="Category:Short description matches Wikidata">Short description matches Wikidata</a></li><li><a href="/wiki/Category:Wikipedia_articles_needing_clarification_from_May_2021" title="Category:Wikipedia articles needing clarification from May 2021">Wikipedia articles needing clarification from May 2021</a></li><li><a href="/wiki/Category:Articles_with_specifically_marked_weasel-worded_phrases_from_September_2022" title="Category:Articles with specifically marked weasel-worded phrases from September 2022">Articles with specifically marked weasel-worded phrases from September 2022</a></li><li><a href="/wiki/Category:Articles_with_example_SQL_code" title="Category:Articles with example SQL code">Articles with example SQL code</a></li></ul></div></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> This page was last edited on 7 February 2025, at 22:25<span class="anonymous-show">&#160;(UTC)</span>.</li> <li id="footer-info-copyright">Text is available under the <a href="/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License" title="Wikipedia:Text of the Creative Commons Attribution-ShareAlike 4.0 International License">Creative Commons Attribution-ShareAlike 4.0 License</a>; additional terms may apply. By using this site, you agree to the <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use" class="extiw" title="foundation:Special:MyLanguage/Policy:Terms of Use">Terms of Use</a> and <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy" class="extiw" title="foundation:Special:MyLanguage/Policy:Privacy policy">Privacy Policy</a>. Wikipedia® is a registered trademark of the <a rel="nofollow" class="external text" href="https://wikimediafoundation.org/">Wikimedia Foundation, Inc.</a>, a non-profit organization.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li> <li id="footer-places-about"><a href="/wiki/Wikipedia:About">About Wikipedia</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Wikipedia:General_disclaimer">Disclaimers</a></li> <li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Code of Conduct</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/en.wikipedia.org">Statistics</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li> <li id="footer-places-mobileview"><a href="//en.m.wikipedia.org/w/index.php?title=Join_(SQL)&amp;mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><picture><source media="(min-width: 500px)" srcset="/static/images/footer/wikimedia-button.svg" width="84" height="29"><img src="/static/images/footer/wikimedia.svg" width="25" height="25" alt="Wikimedia Foundation" lang="en" loading="lazy"></picture></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><picture><source media="(min-width: 500px)" srcset="/w/resources/assets/poweredby_mediawiki.svg" width="88" height="31"><img src="/w/resources/assets/mediawiki_compact.svg" alt="Powered by MediaWiki" lang="en" width="25" height="25" loading="lazy"></picture></a></li> </ul> </footer> </div> </div> </div> <div class="vector-header-container vector-sticky-header-container"> <div id="vector-sticky-header" class="vector-sticky-header"> <div class="vector-sticky-header-start"> <div class="vector-sticky-header-icon-start vector-button-flush-left vector-button-flush-right" aria-hidden="true"> <button class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-sticky-header-search-toggle" tabindex="-1" data-event-name="ui.vector-sticky-search-form.icon"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </button> </div> <div role="search" class="vector-search-box-vue vector-search-box-show-thumbnail vector-search-box"> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail"> <form action="/w/index.php" id="vector-sticky-search-form" class="cdx-search-input cdx-search-input--has-end-button"> <div class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia"> <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <div class="vector-sticky-header-context-bar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-sticky-header-toc" class="vector-dropdown mw-portlet mw-portlet-sticky-header-toc vector-sticky-header-toc vector-button-flush-left" > <input type="checkbox" id="vector-sticky-header-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-sticky-header-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-sticky-header-toc-label" for="vector-sticky-header-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-sticky-header-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div class="vector-sticky-header-context-bar-primary" aria-hidden="true" ><span class="mw-page-title-main">Join (SQL)</span></div> </div> </div> <div class="vector-sticky-header-end" aria-hidden="true"> <div class="vector-sticky-header-icons"> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-talk-sticky-header" tabindex="-1" data-event-name="talk-sticky-header"><span class="vector-icon mw-ui-icon-speechBubbles mw-ui-icon-wikimedia-speechBubbles"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-subject-sticky-header" tabindex="-1" data-event-name="subject-sticky-header"><span class="vector-icon mw-ui-icon-article mw-ui-icon-wikimedia-article"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-history-sticky-header" tabindex="-1" data-event-name="history-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-history mw-ui-icon-wikimedia-wikimedia-history"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only mw-watchlink" id="ca-watchstar-sticky-header" tabindex="-1" data-event-name="watch-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-star mw-ui-icon-wikimedia-wikimedia-star"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-edit-sticky-header" tabindex="-1" data-event-name="wikitext-edit-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-wikiText mw-ui-icon-wikimedia-wikimedia-wikiText"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-ve-edit-sticky-header" tabindex="-1" data-event-name="ve-edit-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-edit mw-ui-icon-wikimedia-wikimedia-edit"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-viewsource-sticky-header" tabindex="-1" data-event-name="ve-edit-protected-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-editLock mw-ui-icon-wikimedia-wikimedia-editLock"></span> <span></span> </a> </div> <div class="vector-sticky-header-buttons"> <button class="cdx-button cdx-button--weight-quiet mw-interlanguage-selector" id="p-lang-btn-sticky-header" tabindex="-1" data-event-name="ui.dropdown-p-lang-btn-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-language mw-ui-icon-wikimedia-wikimedia-language"></span> <span>21 languages</span> </button> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive" id="ca-addsection-sticky-header" tabindex="-1" data-event-name="addsection-sticky-header"><span class="vector-icon mw-ui-icon-speechBubbleAdd-progressive mw-ui-icon-wikimedia-speechBubbleAdd-progressive"></span> <span>Add topic</span> </a> </div> <div class="vector-sticky-header-icon-end"> <div class="vector-user-links"> </div> </div> </div> </div> </div> <div class="mw-portlet mw-portlet-dock-bottom emptyPortlet" id="p-dock-bottom"> <ul> </ul> </div> <script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-5954cc5cd5-m7w5h","wgBackendResponseTime":193,"wgPageParseReport":{"limitreport":{"cputime":"0.445","walltime":"0.615","ppvisitednodes":{"value":2033,"limit":1000000},"postexpandincludesize":{"value":44846,"limit":2097152},"templateargumentsize":{"value":3677,"limit":2097152},"expansiondepth":{"value":12,"limit":100},"expensivefunctioncount":{"value":23,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":71161,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 428.884 1 -total"," 32.22% 138.178 1 Template:Reflist"," 20.02% 85.876 1 Template:SQL"," 19.00% 81.493 1 Template:Navbox"," 18.43% 79.061 1 Template:Short_description"," 16.75% 71.856 1 Template:Cite_book"," 11.05% 47.398 2 Template:Pagetype"," 7.37% 31.624 2 Template:Fix"," 7.35% 31.520 1 Template:Why"," 6.59% 28.273 1 Template:Multiple_image"]},"scribunto":{"limitreport-timeusage":{"value":"0.217","limit":"10.000"},"limitreport-memusage":{"value":7635814,"limit":52428800},"limitreport-logs":"anchor_id_list = table#1 {\n [\"CITEREFPratt2005\"] = 1,\n [\"CITEREFShah2005\"] = 1,\n [\"CITEREFSilberschatzKorthSudarshan2002\"] = 1,\n [\"CITEREFWangWillseySuciu2023\"] = 1,\n [\"CITEREFYuMeng1998\"] = 1,\n [\"Natural_join_in_inner_join\"] = 1,\n}\ntemplate_list = table#1 {\n [\"Anchor\"] = 1,\n [\"By whom\"] = 1,\n [\"Citation\"] = 3,\n [\"Cite arXiv\"] = 1,\n [\"Cite book\"] = 1,\n [\"Cite web\"] = 3,\n [\"Clear\"] = 5,\n [\"DEFAULTSORT:Join (SQL)\"] = 1,\n [\"Dfni\"] = 1,\n [\"Harvnb\"] = 3,\n [\"Math\"] = 1,\n [\"Multiple image\"] = 1,\n [\"Mvar\"] = 6,\n [\"Null result\"] = 16,\n [\"Refbegin\"] = 1,\n [\"Refend\"] = 1,\n [\"Reflist\"] = 1,\n [\"SQL\"] = 1,\n [\"Short description\"] = 1,\n [\"Webarchive\"] = 1,\n [\"Why\"] = 1,\n}\narticle_whitelist = table#1 {\n}\nciteref_patterns = table#1 {\n}\n"},"cachereport":{"origin":"mw-web.codfw.next-88cd69d45-6r8xn","timestamp":"20250305213045","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Join (SQL)","url":"https:\/\/en.wikipedia.org\/wiki\/Join_(SQL)","sameAs":"http:\/\/www.wikidata.org\/entity\/Q2003535","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q2003535","author":{"@type":"Organization","name":"Contributors to Wikimedia projects"},"publisher":{"@type":"Organization","name":"Wikimedia Foundation, Inc.","logo":{"@type":"ImageObject","url":"https:\/\/www.wikimedia.org\/static\/images\/wmf-hor-googpub.png"}},"datePublished":"2004-05-19T11:54:50Z","dateModified":"2025-02-07T22:25:18Z","image":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/d\/d2\/Square_join.png","headline":"SQL clause"}</script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10