SFMC SQL - JOINS
Naveen_SFMC_SQL_Joins
-:JOINS:-
-:JOIN in Salesforce Marketing Cloud:-
In SFMC, A JOIN is used to combine data from multiple Data Extensions (tables) using a common field.
In Salesforce Marketing Cloud, data is usually stored in multiple Data Extensions (DEs) instead of one single table.
JOINs are important because they help combine related data from different DEs using a common field.
Why JOINs Are Important
Without JOINs:👉
- data remains separated
- reports become difficult
- personalization is limited
- segmentation becomes hard
JOINs help marketers connect subscriber data, order data, journey data, and engagement data together.
First of all we created Three Source tables and one Target Table
1. Naveen_Customer_table_Joins
2. Naveen_Order_table_Joins
3. Naveen_self_Join
4. Naveen_Customer_Table_Joins_TargetDE
-----------------------------------------------------------------------------------------------------------------------------
1. Inner Join :-
INNER JOIN returns only the rows that have matching values in both tables
Query:-
Select
CDE.Customer_ID, CDE.Name, CDE.City, ODE.Product
from Naveen_Customer_table_Joins CDE
inner join Naveen_Order_table_Joins ODE
on CDE.Customer_ID = ODE.Customer_ID
Result : Inner Join only return common or matching data from both the table.
LEFT JOIN returns:👉
- All records from the left table
- Matching records from the right table
If no match exists, NULL values are returned from the right table.
Query:-
Select
CDE.Customer_ID, CDE.Name, CDE.City, ODE.Product
from Naveen_Customer_table_Joins CDE
Left join Naveen_Order_table_Joins ODE
on CDE.Customer_ID = ODE.Customer_ID
Result : In result, all the left Table data is fetched and only matching data from right table fetch, Where data is not available for particular Customer_ID - data is null.
RIGHT JOIN returns:👉- all records from the right table
- matching records from the left table
Comments
Post a Comment