{"id":3535,"date":"2025-10-05T00:00:00","date_gmt":"2025-10-04T22:00:00","guid":{"rendered":"https:\/\/tecnologia.euroinnova.com\/join\/"},"modified":"2025-10-14T11:28:52","modified_gmt":"2025-10-14T09:28:52","slug":"join","status":"publish","type":"post","link":"https:\/\/tecnologia.euroinnova.com\/en\/join","title":{"rendered":"JOIN"},"content":{"rendered":"<p>The JOIN statement is one of the most important and widely used concepts in SQL (Structured Query Language). Essentially, it is used to combine rows from two or more tables into one <a href=\"https:\/\/tecnologia.euroinnova.com\/en\/database\/\">database<\/a>, based on a relationship between them. It is an essential tool for working with relational databases, where information is spread across multiple tables. Without the use of JOINs, extracting meaningful data spanning multiple tables would be much more complicated and less efficient.<\/p>\n<h3 id=\"tipos-de-join\"><strong>Types of JOIN<\/strong><\/h3>\n<p>There are several types of JOIN in SQL, each designed to handle different situations and query requirements. The main types of JOIN are described below:<\/p>\n<h4><strong>Inner join<\/strong><\/h4>\n<p>The <strong>Inner join<\/strong> This is the most common type of JOIN. It is used to return only those rows that have matching values in both tables involved. In other words, if the rows in one table do not have a match in the other table, they will not be included in the final result. This type of JOIN is very useful when you want to extract only the data that is relevant to both tables.<\/p>\n<h4><strong>Left join<\/strong><\/h4>\n<p>The <strong>left join<\/strong> (or <strong>left outer join<\/strong>) returns all rows from the left-hand table and the matching rows from the right-hand table. If there is no match, the rows from the right-hand table will appear as NULL in the result. This type of JOIN is useful when you wish to retrieve all rows from the main table, regardless of whether or not they have a match in the secondary table.<\/p>\n<h4><strong>Right join<\/strong><\/h4>\n<p>The <strong>right join<\/strong> (or <strong>right outer join<\/strong>) is similar to a left join, but with the tables reversed. It returns all rows from the table on the right and the matching rows from the table on the left. If there is no match, the rows from the table on the left will appear as NULL in the result. It is used when the right-hand table needs to be prioritised in the query.<\/p>\n<h3 id=\"ejemplos-de-uso\"><strong>Examples of use<\/strong><\/h3>\n<p>To gain a better understanding of how these JOIN sequences work, let\u2019s look at some practical examples.<\/p>\n<h4><strong>Example of an inner join<\/strong><\/h4>\n<p>Let\u2019s suppose we have two tables: <code>Customers<\/code> y <code>Orders<\/code>. The table <code>Customers<\/code> contains information about a shop\u2019s customers, and the table <code>Orders<\/code> contains the orders placed by those customers.<\/p>\n<p>SELECT Customers.Name, Orders.OrderDate<br \/>\nFROM Customers<br \/>\nINNER JOIN Orders<br \/>\nON Customers.CustomerID = Orders.CustomerID;<\/p>\n<p>In this example, the <code>INNER JOIN<\/code> returns a list of customer names along with the dates on which they placed orders, but only for those customers who have placed at least one order.<\/p>\n<h4><strong>Example of a left join<\/strong><\/h4>\n<p>Using the same tables <code>Customers<\/code> y <code>Orders<\/code>, we now want to obtain a list of all customers, including those who have not placed any orders.<\/p>\n<p>SELECT Customers.Name, Orders.OrderDate<br \/>\nFROM Customers<br \/>\nLEFT JOIN Orders<br \/>\nON Customers.CustomerID = Orders.CustomerID;<\/p>\n<p>This <code>LEFT JOIN<\/code> will return a list of all customers, and if a customer has not placed an order, the column <code>Order Date<\/code> will appear as NULL.<\/p>\n<h4><strong>Example of a right join<\/strong><\/h4>\n<p>Finally, let\u2019s see how a <code>Right Join<\/code> using the same tables.<\/p>\n<p>SELECT Customers.Name, Orders.OrderDate<br \/>\nFROM Customers<br \/>\nRIGHT JOIN Orders<br \/>\nON Customers.CustomerID = Orders.CustomerID;<br \/>\nHere, the <code>RIGHT JOIN<\/code> will return all records, including those that may not have a corresponding customer in the table <code>Customers<\/code>. This could happen if, for example, a customer were deleted from the table <code>Customers<\/code> but their orders are still in the database.<\/p>\n<p><strong>Here are some related training courses that might interest you:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/www.euroinnova.com\/master-en-big-data-y-data-science\" target=\"_blank\" rel=\"noopener\">Master\u2019s in Big Data and Data Science<\/a><\/li>\n<li><a href=\"https:\/\/www.euroinnova.com\/master-en-bi-y-big-data\" target=\"_blank\" rel=\"noopener\">Master\u2019s in Business Intelligence and Big Data<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>La secuencia JOIN es uno de los conceptos m\u00e1s importantes y utilizados en SQL (Structured Query Language). B\u00e1sicamente, se utiliza [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25],"tags":[],"class_list":["post-3535","post","type-post","status-publish","format-standard","hentry","category-metaterminos"],"acf":[],"_links":{"self":[{"href":"https:\/\/tecnologia.euroinnova.com\/en\/wp-json\/wp\/v2\/posts\/3535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tecnologia.euroinnova.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tecnologia.euroinnova.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tecnologia.euroinnova.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tecnologia.euroinnova.com\/en\/wp-json\/wp\/v2\/comments?post=3535"}],"version-history":[{"count":0,"href":"https:\/\/tecnologia.euroinnova.com\/en\/wp-json\/wp\/v2\/posts\/3535\/revisions"}],"wp:attachment":[{"href":"https:\/\/tecnologia.euroinnova.com\/en\/wp-json\/wp\/v2\/media?parent=3535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tecnologia.euroinnova.com\/en\/wp-json\/wp\/v2\/categories?post=3535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tecnologia.euroinnova.com\/en\/wp-json\/wp\/v2\/tags?post=3535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}