{"id":22760,"date":"2023-09-21T10:00:00","date_gmt":"2023-09-21T08:00:00","guid":{"rendered":"https:\/\/www.marketinet.com\/blog\/sql-joins-in-salesforce-marketing-cloud\/"},"modified":"2025-04-07T10:07:22","modified_gmt":"2025-04-07T08:07:22","slug":"sql-joins-in-salesforce-marketing-cloud","status":"publish","type":"post","link":"https:\/\/www.marketinet.com\/en\/blog\/sql-joins-in-salesforce-marketing-cloud\/","title":{"rendered":"The Power of SQL Join Tables in SalesForce Marketing Cloud"},"content":{"rendered":"<p><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559740&quot;:240}\">None of what we&#8217;ve discussed so far about using SQL QUERY instead of filtered Data Extensions would make sense, if you didn&#8217;t want to get the most out of it by joining tables. In Marketing Cloud you can join your Data Extensions with others through relationships. In addition, you have the DataViews (very interesting information for segmentation) and even new tables generated by Einstein.<\/span><\/p>\n<p><!--more--><\/p>\n<p>\u00a0<\/p>\n<p><span data-contrast=\"none\">In future articles we will talk about <a href=\"\/en\/thedigitalmarketinglab\/examples-dataviews-sql-query-salesforce-marketing-cloud\" rel=\"noopener\">DataViews<\/a>, because they allow you to do things like sending an email to those who opened a previous email or sending it even to those who did not open it, among many other options.<\/span><\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559740&quot;:240}\">Now we are going to focus on making queries between several tables, what we call JOINS. In this case, we will rely on 2 tables, but this can be made as complicated as you want with more tables and even different JOIN types.<\/span><\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559740&quot;:240}\">To explain it, it is best to use Venn diagrams like we did in school, so you will understand it better. In this case, we are going to see the 7 main JOINs that are used. There are some more, but they are unusual.<\/span><\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559740&quot;:240}\">For this example, we are going to use 2 tables, user and purchase. From the user table, we will get the name, from the purchase table: category, date and amount. Both tables are related to the user_id field.<\/span><\/p>\n<p>\u00a0<\/p>\n<h2>TYPE 1: Left Outer Join\u00a0<\/h2>\n<p>\u00a0<\/p>\n<p>In this first option we want all the data from the user table, and all those that are related to the purchases table. That is, all users, whether they have purchased or not.<\/p>\n<p>\u00a0<\/p>\n<p><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/blog\/marketing-automation\/left-outer-join.png\" alt=\"Left Outer Join\u00a0\" width=\"646\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 803px; --smush-placeholder-aspect-ratio: 803\/605;\" \/><\/p>\n<p>\u00a0<\/p>\n<p><strong><span data-contrast=\"none\">SELECT<\/span><\/strong><span data-contrast=\"none\"> A.name, B.category, B.date, B.amount<\/span><\/p>\n<p><strong><span data-contrast=\"none\">FROM<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">user<\/span><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">A<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">LEFT<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">JOIN<\/span><\/strong><span data-contrast=\"none\"> purchase_user <\/span><span data-contrast=\"none\">B<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">ON<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">A<\/span><span data-contrast=\"none\">.<\/span><span data-contrast=\"none\">id_user<\/span><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">=<\/span><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">B<\/span><span data-contrast=\"none\">.<\/span><span data-contrast=\"none\">id_user<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p>\u00a0<\/p>\n<p><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/undefined-Jan-19-2021-11-56-33-65-AM.png\" alt=\"Table result Left Outer Join\u00a0\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 642px; --smush-placeholder-aspect-ratio: 642\/226;\" \/><\/p>\n<p>\u00a0<\/p>\n<h2>TYPE 2: Left Outer Join with Exclusions<\/h2>\n<p>\u00a0<\/p>\n<p><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/blog\/marketing-automation\/left-outer-join-with-exclusions.png\" alt=\"Left Outer Join with Exclusions\" width=\"650\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 803px; --smush-placeholder-aspect-ratio: 803\/605;\" \/><\/p>\n<p>\u00a0<\/p>\n<p><span lang=\"ES-ES\" data-contrast=\"none\"><span data-ccp-para=\"\">With this JOIN what we get is all the users, except those who match the purchase. In other words, we would be removing all the users who have NOT purchased. Useful, right? The SQL would be:<\/span><\/span><\/p>\n<p><strong><span data-contrast=\"none\">SELECT<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">A<\/span><span data-contrast=\"none\">.<\/span><span data-contrast=\"none\">name<\/span><span data-contrast=\"none\">,<\/span><span data-contrast=\"none\"> B.category, B.date, B.amount<\/span><\/p>\n<p><strong><span data-contrast=\"none\">FROM<\/span><\/strong><span data-contrast=\"none\"> user <\/span><span data-contrast=\"none\">A<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">LEFT<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">JOIN<\/span><\/strong><span data-contrast=\"none\"> purchase_user B<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">ON<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">A<\/span><span data-contrast=\"none\">.user_id = B.user_id<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">WHERE<\/span><\/strong><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">B<\/span><span data-contrast=\"none\">.user_id <\/span><strong><span data-contrast=\"none\">IS<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">NULL<\/span><\/strong><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p>\u00a0<\/p>\n<p>And the result is in this table\u2026<\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/undefined-Jan-19-2021-12-01-51-88-PM.png\" alt=\"Tabla resultado Left Outer Join with Exclusions\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 642px; --smush-placeholder-aspect-ratio: 642\/66;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<p>{{cta(&#8216;07552fae-6d5c-4f5c-9eef-393170a82bef&#8217;,&#8217;justifycenter&#8217;)}}<\/p>\n<p>\u00a0<\/p>\n<h2><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">TYPE 3: Right Outer Join\u00a0<\/span><\/h2>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><span lang=\"ES-ES\" data-contrast=\"none\">In this option we want all the data from the purchases table and all those that are related to the users table. In theory, this should match in its entirety, but in this case we have forced it not to be like this as if some purchase were not related to any user (sometimes it is done for units given up for lost, etc.):<\/span><\/span><\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/blog\/marketing-automation\/right-outer-join.png\" alt=\"Right Outer Join\u00a0\" width=\"647\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 803px; --smush-placeholder-aspect-ratio: 803\/605;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<p><strong><span data-contrast=\"none\">SELECT<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">A<\/span><span data-contrast=\"none\">.<\/span><span data-contrast=\"none\">name<\/span><span data-contrast=\"none\">,<\/span><span data-contrast=\"none\"> B.category, B.date, B.amount<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">FROM<\/span><\/strong><span data-contrast=\"none\"> user <\/span><span data-contrast=\"none\">A<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">RIGHT<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">JOIN<\/span><\/strong><span data-contrast=\"none\"> purchase_user <\/span><span data-contrast=\"none\">B<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">ON<\/span><\/strong><span data-contrast=\"none\"> A.user_id = B.user_id<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/undefined-Jan-19-2021-12-04-34-95-PM.png\" alt=\"Tabla resultado Right Outer Join\u00a0\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 650px; --smush-placeholder-aspect-ratio: 650\/232;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<h2><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">TYPE 4: Right Outer Join with exclusions<\/span><\/h2>\n<p>\u00a0<\/p>\n<p>With this type, we would remove all \u201corphan\u201d purchases.<\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/blog\/marketing-automation\/right-outer-join-with-exclusions.png\" alt=\"Right Outer Join with exclusions\" width=\"647\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 803px; --smush-placeholder-aspect-ratio: 803\/605;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<p><strong><span data-contrast=\"none\">SELECT<\/span><\/strong><span data-contrast=\"none\"> A.name, B.category, B.date, B.amount<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">FROM<\/span><\/strong><span data-contrast=\"none\"> user <\/span><span data-contrast=\"none\">A<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">RIGHT<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">JOIN<\/span><\/strong><span data-contrast=\"none\"> purchase B_user<\/span><span data-contrast=\"none\">\u00a0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">ON<\/span><\/strong><span data-contrast=\"none\"> A.user_id = B.user_id<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">WHERE<\/span><\/strong><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<br \/><\/span><span data-contrast=\"none\">A.user_id <\/span><strong><span data-contrast=\"none\">IS<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">NULL<\/span><\/strong><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/undefined-Jan-19-2021-12-06-15-81-PM.png\" alt=\"Tabla resultado Right Outer Join with exclusions\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 642px; --smush-placeholder-aspect-ratio: 642\/66;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<h2><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">TYPE 5: Inner Join\u00a0<\/span><\/h2>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"> We would almost say that this type<strong> is the classic one, <\/strong>it is<strong> the pure intersection of sets and only extracts the matching ones between both tables.<\/strong><\/span><\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/blog\/marketing-automation\/inner-join.png\" alt=\"Inner Join\u00a0\" width=\"634\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 803px; --smush-placeholder-aspect-ratio: 803\/605;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<p><strong><span data-contrast=\"none\">SELECT<\/span><\/strong><span data-contrast=\"none\"> A.name, B.category, B.date, B.amount<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">FROM<\/span><\/strong><span data-contrast=\"none\"> user<\/span><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">A<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">INNER<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">JOIN<\/span><\/strong><span data-contrast=\"none\"> purchase_user B<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">ON<\/span><\/strong><span data-contrast=\"none\"> A.user_id = B.user_id<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/undefined-Jan-19-2021-12-08-34-57-PM.png\" alt=\"Table results Inner Join\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 647px; --smush-placeholder-aspect-ratio: 647\/189;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<h2><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">TYPE 6: Full Outer Join<\/span><\/h2>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">With<strong> full Outer join,<\/strong> as the word FULL indicates<strong>, we would get everything, users whether or not they match purchases, purchases even if they do not match users and the intersection of both.<\/strong><\/span><\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/blog\/marketing-automation\/full-outer-join.png\" alt=\"Full Outer Join\" width=\"641\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 803px; --smush-placeholder-aspect-ratio: 803\/605;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<p><strong><span data-contrast=\"none\">SELECT<\/span><\/strong><span data-contrast=\"none\"> A.name, B.category, B.date, B.amount<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">FROM<\/span><\/strong><span data-contrast=\"none\"> user A<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">FULL<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">OUTER<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">JOIN<\/span><\/strong><span data-contrast=\"none\"> purchase_user B<\/span><\/p>\n<p><strong><span data-contrast=\"none\">ON<\/span><\/strong><span data-contrast=\"none\"> A.user_id = B.user_id<\/span><\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/undefined-Jan-19-2021-12-10-04-08-PM.png\" alt=\"Tabla resultado Full Outer Join\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 644px; --smush-placeholder-aspect-ratio: 644\/270;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<h2><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">TYPE 7: Outer Join<\/span><\/h2>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">In the latter case <strong>we would remove what we have said were the \u201corphan\u201d purchases and the users who have not purchased.<\/strong><\/span><\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/blog\/marketing-automation\/outer-join.png\" alt=\"Outer Join\" width=\"635\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 803px; --smush-placeholder-aspect-ratio: 803\/605;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<p><strong><span data-contrast=\"none\">SELECT<\/span><\/strong><span data-contrast=\"none\"> A.name, B.category,B.date,B.amount<\/span><\/p>\n<p><strong><span data-contrast=\"none\">FROM<\/span><\/strong><span data-contrast=\"none\"> user A<\/span><\/p>\n<p><strong><span data-contrast=\"none\">FULL<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">OUTER<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">JOIN<\/span><\/strong><span data-contrast=\"none\"> purchase_user B<\/span><\/p>\n<p><strong><span data-contrast=\"none\">ON<\/span><\/strong><span data-contrast=\"none\"> A.user_id = B.user_id<\/span><\/p>\n<p><strong><span data-contrast=\"none\">WHERE<\/span><\/strong><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">A.user_id <\/span><strong><span data-contrast=\"none\">IS<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">NULL<\/span><\/strong><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong><span data-contrast=\"none\">OR<\/span><\/strong><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">B.user_id <\/span><strong><span data-contrast=\"none\">IS<\/span><\/strong><span data-contrast=\"none\">\u00a0<\/span><strong><span data-contrast=\"none\">NULL<\/span><\/strong><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p>\u00a0<\/p>\n<p><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"><img decoding=\"async\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/06\/undefined-Jan-19-2021-12-11-49-02-PM.png\" alt=\"Table results Outer Join\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 646px; --smush-placeholder-aspect-ratio: 646\/112;\" \/><\/span><\/p>\n<p>\u00a0<\/p>\n<h2><strong>CONCLUSION<\/strong><\/h2>\n<p>\u00a0<\/p>\n<p>If you want to get the most out of Marketing Cloud and the <a href=\"https:\/\/617233.hubspotpreview-na1.com\/blog\/pasos-para-desarrollar-estrategia-email-marketing-efectiva\" rel=\"noopener\" target=\"_blank\">email marketing strategy,<\/a> which is ultimately the objective, the essential thing is to know how to correctly segment our audiences. To make these segmentations correctly it is important to be able to combine several tables. This is where JOINs come into play, something that you will have to master in order to get the most out of your segmentations through SQL QUERY.<\/p>\n<p>\u00a0<\/p>\n<p><strong>{{cta(&#8217;52fa9c99-860e-4fbd-b8e0-8084060f20e8&#8242;,&#8217;justifycenter&#8217;)}}<\/strong><\/p>\n<p>\u00a0<\/p>\n<hr \/>\n<p>If you liked this article, you might also be interested in:<\/p>\n<p>\u00a0<\/p>\n<ul>\n<li>\n<p><a href=\"\/blog\/filtered-data-extension-en-marketing-cloud\" rel=\"noopener\">Filtered Data Extension in Marketing Cloud and aspects to take into account<\/a><\/p>\n<\/li>\n<li>\n<p><a id=\"__hsNewLink\" href=\"\/blog\/como-usar-personalizaciones-marketing-cloud\" rel=\"noopener\">How to use simple customizations in Marketing Cloud<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.marketinet.com\/ebooks\/ecosistema-datos-salesforce-marketing-cloud?utm_source=blog&amp;utm_medium=inbound&amp;utm_campaign=cta_recurso_blog_ebook_ecosistema_de_datos_en_salesforce_marketing_cloud\"><img decoding=\"async\" width=\"800\" height=\"200\" data-src=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/01\/800x200_banner_ebook_ecosistema_de_datos_en_salesforce_marketing_cloud.jpg\" alt=\"eBook Ecosistema de datos en Salesforce Marketing Cloud \" class=\"wp-image-1176 lazyload\" data-srcset=\"https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/01\/800x200_banner_ebook_ecosistema_de_datos_en_salesforce_marketing_cloud.jpg 800w, https:\/\/www.marketinet.com\/wp-content\/uploads\/2024\/01\/800x200_banner_ebook_ecosistema_de_datos_en_salesforce_marketing_cloud-480x120.jpg 480w\" data-sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 800px, 100vw\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 800px; --smush-placeholder-aspect-ratio: 800\/200;\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>None of what we&#8217;ve discussed so far about using SQL QUERY instead of filtered Data Extensions would make sense, if you didn&#8217;t want to get the most out of it by joining tables. In Marketing Cloud you can join your Data Extensions with others through relationships. In addition, you have the DataViews (very interesting information [&hellip;]<\/p>\n","protected":false},"author":36,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1],"tags":[165],"class_list":["post-22760","post","type-post","status-publish","format-standard","hentry","category-sin-categorizar","tag-sf-marketing-cloud"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/posts\/22760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/comments?post=22760"}],"version-history":[{"count":0,"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/posts\/22760\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/media?parent=22760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/categories?post=22760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.marketinet.com\/en\/wp-json\/wp\/v2\/tags?post=22760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}