0

I am attempting to build a combined data extension from 3 other related data extensions via Query & Automation Studio SQL Query.

I have successfully (though I'm not sure that the # of records I pulled is correct) done this with 2 data extensions using this SQL snippet:

SELECT
c.Contact_Id,
c.Device_Id,
c.Email,
c.Platform,
c.Platform_User_Id,
c.First_Name,
c.Last_Name,
c.Created_At,
c.Last_Login_At,
sl.id as squadlocker_Id,
sl.Organization_Id,
sl.Team_Id,
sl.Store_Id,
sl.Created_At as sl_Created_At,
sl.Updated_At as sl_Updated_At,
sl.Open_Date,
sl.Closed_Date,
sl.Created_By_User_Id,
sl.User_Id
FROM
ENT.[User] c
INNER JOIN ENT.[Squadlockers] sl ON c.Platform_User_Id = sl.User_Id

However, when I attempt adding a 3rd DE I do not get any results. Snippet:

SELECT
usr.Contact_Id,
usr.Device_Id,
usr.Email,
usr.Platform,
usr.Platform_User_Id,
usr.First_Name,
usr.Last_Name,
usr.Created_At,
usr.Last_Login_At,
sl.id as squadlocker_Id,
sl.Organization_Id,
sl.Team_Id,
sl.Store_Id,
sl.Created_At as sl_Created_At,
sl.Updated_At as sl_Updated_At,
sl.Open_Date,
sl.Closed_Date,
sl.Created_By_User_Id,
sl.User_Id,
tea.Id,
tea.Name
FROM
ENT.[User] usr
INNER JOIN ENT.[Squadlockers] sl ON usr.Platform_User_Id = sl.User_Id
INNER JOIN ENT.[Season_Teams] tea ON sl.User_Id = tea.Id

Not sure what I have wrong here. I've read the SFMC documentation on Query Activity, but have found that the SF documentation on this is a bit lacking.

1
  • Are you using the same data extension or a new one?
    – 0xsegfault
    Commented May 23, 2017 at 7:36

1 Answer 1

2

Using INNER JOINs means that only User_ids with a match in User, Squadlockers and Season_Teams will be returned. Is this accurate with what you know about your data?

If you're not sure, I'd suggest using LEFT JOINs and reviewing the results, LEFT JOINs will return rows from User even if no match is found in Squadlockers and Season_Teams:

SELECT
usr.Contact_Id,
usr.Device_Id,
usr.Email,
usr.Platform,
usr.Platform_User_Id,
usr.First_Name,
usr.Last_Name,
usr.Created_At,
usr.Last_Login_At,
sl.id as squadlocker_Id,
sl.Organization_Id,
sl.Team_Id,
sl.Store_Id,
sl.Created_At as sl_Created_At,
sl.Updated_At as sl_Updated_At,
sl.Open_Date,
sl.Closed_Date,
sl.Created_By_User_Id,
sl.User_Id,
tea.Id,
tea.Name
FROM
ENT.[User] usr
LEFT JOIN ENT.[Squadlockers] sl ON usr.Platform_User_Id = sl.User_Id
LEFT JOIN ENT.[Season_Teams] tea ON sl.User_Id = tea.Id
1
  • Follow-up - Thanks for the help. There was something incorrect on the data side of things. The query ended up being correct. Commented Jun 11, 2017 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .