[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-656138-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-656138-en":130},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","outer-joins-what-is-an-outer-join-leftright-and-full-outer-join","Outer Joins - What Is an OUTER JOIN? - LEFT/RIGHT and FULL OUTER JOIN","","Explains the concept and purpose of OUTER JOINs in SQL, contrasting them with INNER JOINs by including both matching and unmatched rows from joined tables. Uses a students-and-classes scheduling example to illustrate how NULLs appear in columns when no matching record exists. Covers how LEFT OUTER JOIN and RIGHT OUTER JOIN differ based on which table is treated as the left or right side in the query. Introduces the role of the ON clause and previews syntax for building OUTER JOINs.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/outer-joins-what-is-an-outer-join-leftright-and-full-outer-join/656138/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/outer-joins-what-is-an-outer-join-leftright-and-full-outer-join/656138.png","ImageObject",300,407,{"name":42,"@type":43},"Genevieve","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-30","2026-10-25",true,{"@type":52,"interactionType":53,"userInteractionCount":33},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"What does an OUTER JOIN return that an INNER JOIN does not?","Question",{"text":62,"@type":63},"An OUTER JOIN returns both the rows that match your join criteria and the rows that don’t match from one or both tables. An INNER JOIN returns only rows where the join condition matches.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"When an OUTER JOIN finds no matching row, what appears in the result set?",{"text":67,"@type":63},"The database returns NULL values in all columns from the table that lacks a matching row for that join.",{"name":69,"@type":60,"acceptedAnswer":70},"How do LEFT OUTER JOIN and RIGHT OUTER JOIN differ?",{"text":71,"@type":63},"LEFT OUTER JOIN returns all rows from the left-named table plus matching rows from the right-named table. RIGHT OUTER JOIN returns all rows from the right-named table plus matching rows from the left-named table.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},656138,1793029889,{"code":4,"msg":81,"data":82},"success",[83,87,91,95,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":84,"show_sort_weight":85,"slug":86},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Exam",70,"exam",{"id":96,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},5,"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":96,"slug":129},19,"General","general",{"code":4,"msg":81,"data":131},{"doc_id":78,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":33,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":144,"read_time":145},1374391974585,"https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c","9  \nOUTER JOINs  \n“The only difference between a problem and a solution is people understand the solution.”  \n—Charles Franklin Kettering Inventor, 1876–1958  \nTopics Covered in This Chapter  \nWhat Is an OUTER JOIN?  \nThe LEFT/RIGHT OUTER JOIN  \nThe FULL OUTER JOIN  \nUses for OUTER JOINs  \nSample Statements  \nSummary  \nProblems for You to Solve  \nIn the previous chapter, we covered all the “ins” of JOINs—linking two or more tables or result sets using INNER JOIN to find all the rows that match. Now it’s time to talk about the“outs”—linking tables and finding out not only the rows that match but also the rows that don’t match.  \nWhat Is an OUTER JOIN?  \nAs we explained in the previous chapter, the SQL Standard defines several types of JOIN operations to link two or more tables or result sets. An OUTER JOIN asks your database system to return not only the rows that match on the criteria you specify but also the unmatched rows from either one or both of the two sets you want to link.  \nLet’s suppose, for example, that you want to fetch information from the School Scheduling database about students and the classes for which they’re registered. As you learned in the previous chapter, an INNER JOIN returns only students who have registered for a class and classes for which a student has registered. It won’t return any students who have been accepted at the school but haven’t signed up for any classes yet, nor will it return any classes that are on the schedule but for which no student has yet shown an interest.  \nWhat if you want to list all students and the classes for which they are registered, if any? Conversely, suppose you want a list of all the classes and the students who have registered for those classes, if any. To solve this sort of problem, you need to ask for an OUTER JOIN.  \nFigure 9–1 uses a set diagram to show one possible relationship between students and classes. As you can see, a few students haven’t registered for a class yet, and a few classes do not yet have any students signed up to take the class.  \nStudents  \nClasses  \nStudents and the Classes for Which They Are Registered  \nFigure 9–1 A possible relationship between students and classes  \nIf you ask for all students and the classes for which they are registered, you’ll get a result set resembling Figure 9–2.  \nYou might ask,“What will I see for the students who haven’t registered for any classes?”If you remember the concept of a Null or “nothing”value discussed in Chapter 5, Getting More Than Simple Columns, you know what you’ll see: When you ask for all students joined with any classes, your database system will return a Null value in all columns from the Classes table  \nStudents Not Yet Registered  \nStudents and the Classes for Which They Are Registered  \nStudents  \nFigure 9–2 All students and the classes for which they are registered  \nwhen it finds a student who is not yet registered for any classes. If you think about the concept of a difference between two sets (discussed in Chapter 7, Thinking in Sets), the rows with a Null value in the columns from the Classes table represent the difference between the set of all students and the set of students who have registered for a class.  \nLikewise, if you ask for all classes and any students who registered for classes, the rows with Null values in the columns from the Students table represent the difference between the set of all classes and the set of classes for which students have registered. As we promised, using an OUTER JOIN with a test for Null values is an alternate way to discover the difference between two sets. Unlike a true EXCEPT operation that matches on entire rows from the two sets, you can specify the match in a JOIN operation on just a few specific columns (usually the primary key and the foreign key) .  \nThe LEFT/RIGHT OUTER JOIN  \nYou’ll generally use the OUTER JOIN form that asks for all the rows from one table or result set and any matching rows from a second table or result set. Todo th","cbCail05SGHnV7Ie","https://ap.wps.com/l/cbCail05SGHnV7Ie","pdf",483012,46,"English","# What Is an OUTER JOIN?\n## The LEFT/RIGHT OUTER JOIN\n## The FULL OUTER JOIN\n# Uses for OUTER JOINs\n# Sample Statements\n# Summary\n# Problems for You to Solve","[{\"question\":\"What does an OUTER JOIN return that an INNER JOIN does not?\",\"answer\":\"An OUTER JOIN returns both the rows that match your join criteria and the rows that don’t match from one or both tables. An INNER JOIN returns only rows where the join condition matches.\"},{\"question\":\"When an OUTER JOIN finds no matching row, what appears in the result set?\",\"answer\":\"The database returns NULL values in all columns from the table that lacks a matching row for that join.\"},{\"question\":\"How do LEFT OUTER JOIN and RIGHT OUTER JOIN differ?\",\"answer\":\"LEFT OUTER JOIN returns all rows from the left-named table plus matching rows from the right-named table. RIGHT OUTER JOIN returns all rows from the right-named table plus matching rows from the left-named table.\"}]","Outer Joins - What Is an OUTER JOIN? - LEFT/RIGHT and FULL OUTER JOIN | PDF",1792966689,116]