{"id":64,"date":"2009-04-04T12:24:26","date_gmt":"2009-04-04T10:24:26","guid":{"rendered":"http:\/\/unckel.com\/blog\/?p=64"},"modified":"2019-12-07T22:31:31","modified_gmt":"2019-12-07T21:31:31","slug":"sql-unterschied-zwischen-left-join-right-join-und-inner-join-unter-access","status":"publish","type":"post","link":"https:\/\/unckel.de\/blog\/sql-unterschied-zwischen-left-join-right-join-und-inner-join-unter-access\/","title":{"rendered":"SQL: Unterschied zwischen LEFT JOIN, RIGHT JOIN und INNER JOIN unter Access"},"content":{"rendered":"<p>Anhand von Code-Beispielen, ohne viel Erkl\u00e4rung, soll hier kurz der Unterschied der JOINs unter Access aufgezeigt werden.<\/p>\n<p><strong>Die Ausgangstabellen:<\/strong><\/p>\n<p><b>Categories<\/b><\/p>\n<table class=\"contentDataTable\">\n<thead>\n<tr>\n<th>ID<\/th>\n<th>Category<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>Funiture<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Automobiles<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Buildings<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>Computer<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><b>Articles<\/b><\/p>\n<table class=\"contentDataTable\">\n<thead>\n<tr>\n<th>ID<\/th>\n<th>CategoryID<\/th>\n<th>Article<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>1<\/td>\n<td>Table<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>1<\/td>\n<td>Chair<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>2<\/td>\n<td>Car<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>2<\/td>\n<td>Truck<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>4<\/td>\n<td>Keyboard<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>4<\/td>\n<td>Mouse<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>5<\/td>\n<td>Hand<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td>5<\/td>\n<td>Foot<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Alle Artikel mit dazugeh\u00f6riger Kategorie, auch die Artikel ohne Kategorie:<\/strong><\/p>\n<pre>SELECT Articles.Article, Categories.Category\nFROM Articles LEFT JOIN Categories\nON Articles.CategoryID = Categories.ID<\/pre>\n<table class=\"contentDataTable\">\n<thead>\n<tr>\n<th>Article<\/th>\n<th>Category<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Table<\/td>\n<td>Funiture<\/td>\n<\/tr>\n<tr>\n<td>Chair<\/td>\n<td>Funiture<\/td>\n<\/tr>\n<tr>\n<td>Car<\/td>\n<td>Automobiles<\/td>\n<\/tr>\n<tr>\n<td>Truck<\/td>\n<td>Automobiles<\/td>\n<\/tr>\n<tr>\n<td>Keyboard<\/td>\n<td>Computer<\/td>\n<\/tr>\n<tr>\n<td>Mouse<\/td>\n<td>Computer<\/td>\n<\/tr>\n<tr>\n<td>Hand<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Foot<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Nur Artikel mit dazugeh\u00f6riger Kategorie, auch die Kategorien ohne Artikel:<\/strong><\/p>\n<pre>SELECT Articles.Article, Categories.Category\nFROM Articles RIGHT JOIN Categories\nON Articles.CategoryID = Categories.ID<\/pre>\n<table class=\"contentDataTable\">\n<thead>\n<tr>\n<th>Article<\/th>\n<th>Category<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Table<\/td>\n<td>Funiture<\/td>\n<\/tr>\n<tr>\n<td>Chair<\/td>\n<td>Funiture<\/td>\n<\/tr>\n<tr>\n<td>Car<\/td>\n<td>Automobiles<\/td>\n<\/tr>\n<tr>\n<td>Truck<\/td>\n<td>Automobiles<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>Buildings<\/td>\n<\/tr>\n<tr>\n<td>Keyboard<\/td>\n<td>Computer<\/td>\n<\/tr>\n<tr>\n<td>Mouse<\/td>\n<td>Computer<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Nur Artikel mit dazugeh\u00f6riger Kategorie, (keine leeren Artikel und Kategorien):<\/strong><\/p>\n<pre>SELECT Articles.Article, Categories.Category\nFROM Articles INNER JOIN Categories\nON Articles.CategoryID = Categories.ID\n\n- oder -\n\nSELECT  Articles.Article, Categories.Category\nFROM Articles, Categories\nWHERE Articles.CategoryID = Categories.ID;<\/pre>\n<table class=\"contentDataTable\">\n<thead>\n<tr>\n<th>Article<\/th>\n<th>Category<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Table<\/td>\n<td>Funiture<\/td>\n<\/tr>\n<tr>\n<td>Chair<\/td>\n<td>Funiture<\/td>\n<\/tr>\n<tr>\n<td>Car<\/td>\n<td>Automobiles<\/td>\n<\/tr>\n<tr>\n<td>Truck<\/td>\n<td>Automobiles<\/td>\n<\/tr>\n<tr>\n<td>Keyboard<\/td>\n<td>Computer<\/td>\n<\/tr>\n<tr>\n<td>Mouse<\/td>\n<td>Computer<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Anhand von Code-Beispielen, ohne viel Erkl\u00e4rung, soll hier kurz der Unterschied der JOINs unter Access aufgezeigt werden. Die Ausgangstabellen: Categories ID Category 1 Funiture 2 Automobiles 3 Buildings 4 Computer Articles ID CategoryID Article 1 1 Table 2 1 Chair 3 2 Car 4 2 Truck 5 4 Keyboard 6 4 Mouse 7 5 Hand [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-webdesign"],"_links":{"self":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":1,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":846,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions\/846"}],"wp:attachment":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}