How-to join two audience lists together using Power Audiences
While technically you can use a variety of SQL functions to join two lists, this explainer articulates a simple, consistent approach to reduce SQL errors when creating power audiences.
For the initial migration – make sure internal_id has been removed and replaced with sort_order.
Instructions
Use the following SELECT / FROM / WHERE clauses to specify attributes of interest when combining two lists.
LEFT JOIN is possible but not recommended. This is because it pulls in more data than is needed and is an overall slower operation, thus slowing down activation times.
SELECT clause explained
The SELECT clause specifies what columns you are pulling from each list.
created_at and sort_order are automatically generated for each list. You will need to specify them from one of the tables, though it does not matter which one.
NOW() as updated_at
updated_at is an automatically generated attribute for the Power Audience list.
Make sure to include NOW() as updated_at in your SQL to avoid an error
Key Attribute
If you’re combining two lists, there will be a key attribute you index on to combine (usually email).
If you want to rename an attribute to be different in the Power Audience from what it was called in its original list, use as to specify that name change
You will need to specify from which list each attribute is being referenced
e.g. not attr_myAttribute but list1.attr_myAttribute
FROM clause explained
Use the FROM clause to declare from which list where attributes of interest are coming from
You can use the CRM List Reference button to easily find the right lists to put in the { }
Whatever you name your lists here will need to be referenced for each attribute in your SELECT clause
WHERE clause explained
This clause specifies your key attribute(s) that overlap in the two tables you are combining
Simply set your key attribute from both columns equal to each other
You can also use the WHERE clause to build segments into your Power Audience (e.g. filtering by purchasers of specific product categories or last purchase date).
You should now understand the logic behind the SQL requirements of Power Audiences.
Deprecated Functions
internal_id used to be the method for identifying the key attribute shared between lists. This logic has been removed. Use the attribute that determines the uniqueness of your audience instead.
For CRM or Transaction lists, this is the first email, phone, or mobile_id attribute
For Data lists this is the combination of the unique_id_attributes that were specified
external_id has also been removed