{"id":80,"date":"2014-05-22T13:13:00","date_gmt":"2014-05-22T12:13:00","guid":{"rendered":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/22\/what-is-self-join-and-when-would-you-use-it-2\/"},"modified":"2014-05-22T13:13:00","modified_gmt":"2014-05-22T12:13:00","slug":"what-is-self-join-and-when-would-you-use-it-2","status":"publish","type":"post","link":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/22\/what-is-self-join-and-when-would-you-use-it-2\/","title":{"rendered":"What is SELF JOIN and when would you use it?"},"content":{"rendered":"<div class='booster-block booster-read-block'>\n                <div class=\"twp-read-time\">\n                \t<i class=\"booster-icon twp-clock\"><\/i> <span>Read Time:<\/span>19 Second                <\/div>\n\n            <\/div><div dir=\"ltr\" style=\"text-align: left;\">\n<\/p>\n<ul style=\"text-align: left;\">\n<li><span style=\"background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804800033569336px;\"><span style=\"font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: normal; text-align: justify;\">The SQL&nbsp;<\/span><b style=\"font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: normal; margin: 0px; padding: 0px; text-align: justify;\">SELF JOIN<\/b><span style=\"font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: normal; text-align: justify;\">&nbsp;is used to join a table to itself<\/span><\/span><\/li>\n<li><span style=\"background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804800033569336px;\">You use a self join when a table references data in itself.<\/span><\/li>\n<li><span style=\"background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804800033569336px;\">SQL self-join simply is a normal join which is used to join a table to itself.<\/span><\/li>\n<\/ul>\n<p>\nExample:<\/p>\n<pre style=\"background-color: #eeeeee; border: 1px solid rgb(214, 214, 214); font-size: 12px; margin-bottom: 10px; overflow: auto; padding: 5px; width: 549.765625px;\"><span style=\"margin: 0px; padding: 0px;\"><span style=\"font-family: 'Times New Roman'; margin: 0px; padding: 0px; white-space: normal;\">SELECT a<\/span><span style=\"color: #666600; font-family: 'Times New Roman'; margin: 0px; padding: 0px; white-space: normal;\">.<\/span><span style=\"font-family: 'Times New Roman'; margin: 0px; padding: 0px; white-space: normal;\">column_name<\/span><span style=\"color: #666600; font-family: 'Times New Roman'; margin: 0px; padding: 0px; white-space: normal;\">,<\/span><span style=\"font-family: 'Times New Roman'; margin: 0px; padding: 0px; white-space: normal;\">&nbsp;b<\/span><span style=\"color: #666600; font-family: 'Times New Roman'; margin: 0px; padding: 0px; white-space: normal;\">.<\/span><span style=\"font-family: 'Times New Roman'; margin: 0px; padding: 0px; white-space: normal;\">column_name<\/span><span style=\"color: #666600; font-family: 'Times New Roman'; margin: 0px; padding: 0px; white-space: normal;\">...<\/span><\/span><\/pre>\n<pre style=\"background-color: #eeeeee; border: 1px solid rgb(214, 214, 214); font-size: 12px; margin-bottom: 10px; overflow: auto; padding: 5px; width: 549.765625px;\"><span style=\"margin: 0px; padding: 0px;\">FROM table1 a,<\/span>table1 b<\/pre>\n<pre style=\"background-color: #eeeeee; border: 1px solid rgb(214, 214, 214); font-size: 12px; margin-bottom: 10px; overflow: auto; padding: 5px; width: 549.765625px;\"><span style=\"margin: 0px; padding: 0px;\">WHERE a<\/span><span style=\"color: #666600; margin: 0px; padding: 0px;\">.<\/span><span style=\"margin: 0px; padding: 0px;\">common_field <\/span><span style=\"color: #666600; margin: 0px; padding: 0px;\">=<\/span><span style=\"margin: 0px; padding: 0px;\"> b<\/span><span style=\"color: #666600; margin: 0px; padding: 0px;\">.<\/span><span style=\"margin: 0px; padding: 0px;\">common_field<\/span><span style=\"color: #666600; margin: 0px; padding: 0px;\">;<\/span><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The SQL&nbsp;SELF JOIN&nbsp;is used to join a table to itself You use a self join when a table references data in itself. SQL self-join simply is a normal join which is used to join a table to itself. Example: SELECT a.column_name,&nbsp;b.column_name&#8230; FROM table1 a,table1 b WHERE a.common_field = b.common_field;<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[34,27],"tags":[],"class_list":["post-80","post","type-post","status-publish","format-standard","hentry","category-ibm","category-sql"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Himanshu Namdeo","author_link":"https:\/\/debuggersspace.com\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"The SQL&nbsp;SELF JOIN&nbsp;is used to join a table to itself You use a self join when a table references data in itself. SQL self-join simply is a normal join which is used to join a table to itself. Example: SELECT a.column_name,&nbsp;b.column_name... FROM table1 a,table1 b WHERE a.common_field = b.common_field;","_links":{"self":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/80"}],"collection":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":0,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"wp:attachment":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}