{"id":2082,"date":"2014-12-11T12:08:22","date_gmt":"2014-12-11T20:08:22","guid":{"rendered":"http:\/\/www.wellgolly.com\/?p=2082"},"modified":"2015-04-07T08:46:23","modified_gmt":"2015-04-07T15:46:23","slug":"mysql-self-join","status":"publish","type":"post","link":"https:\/\/www.wellgolly.com\/?p=2082","title":{"rendered":"mySQL Self-join"},"content":{"rendered":"<p>Looking through my tables, I don\u2019t have any where a self-join makes any sense. I do have one table where it will work. In the Minimal Pairs game, each word is associated with another word. A pair might be \u201cstop &#8211; top\u201d or \u201crake &#8211; wake\u201d.  We have a picture for each word and by doing a self-join, we can see which pictures are duplicated.<br \/>\n<pre><code class=\"preserve-code-formatting\">\nSELECT * \nFROM Pairs AS t1 \nINNER JOIN Pairs AS t2 \nON t1.word1 = t2.word2\n<\/code><\/pre><br \/>\nThe result shows that two images, key and car, are used twice.<br \/>\n<img decoding=\"async\" src=\"\/images\/Self-Join.png\" alt=\"Self-Join\" \/><\/p>\n<p>If you like WHERE syntax, this is it:<br \/>\n<pre><code class=\"preserve-code-formatting\">\nSELECT * \nFROM Pairs AS t1, Pairs AS t2 \nWHERE t1.word1 = t2.word2\n<\/code><\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Looking through my tables, I don\u2019t have any where a self-join makes any sense. I do have one table where it will work. In the Minimal Pairs game, each word is associated with another word. A pair might be \u201cstop &#8211; top\u201d or \u201crake &#8211; wake\u201d. We have a picture for each word and by &hellip; <a href=\"https:\/\/www.wellgolly.com\/?p=2082\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">mySQL Self-join<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-2082","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2082","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2082"}],"version-history":[{"count":0,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2082\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}