What is SQL?
SQL (Structured Query Language) is a language used to create, update and read data from a database. In the context of Vero Connect, SQL allows you to specify which users (recipients) in your database that you want to include in your message’s audience, and which data related to that user you would like to access in order to personalize the content of your message.The Structure of a Query
While SQL is a powerful query language with a complex syntax, at it’s heart there are three basic components of a query you would use in Vero Connect:- The
SELECTstatement: which properties in the data queried you want to have access to. - The
FROMstatement: which table you want to pull this data from. - The
WHEREstatement: narrows down which specific users (recipients) you want the database to return.
SELECT
What theSELECT statement says is that a row in my_users_table may have multiple columns but the columns we are interested in are the addressable_email, first_name, last_name and language columns. It’s always better to only pull down the data we need, which is why we carefully specify just those columns we’ll use to tell Vero where to send your message and the properties needed to personalize that content.
You may have noticed the line addressable_email AS email. The AS keyword in SQL allows us to label the column something differently in the result that is returned. In this case, Vero is expecting the query results to include an email column. As this column is called addressable_email in my_users_table, we ensure the results return that column as email so Vero knows that it can use that information as an endpoint to send the message to.
FROM
TheFROM keyword is used to tell the database which table we are querying. In our query, we’ll be looking at the table my_users_table. Depending on the source of your data, the FROM statement may be more complex than this.
WHERE
TheWHERE statement is the part of the query that allows you to specify exactly which rows of data the database should return. This will usually involve a comparison against one or more of the columns in the database to some value or range of values.
In our specific case, we are asking the database to return only those users who meet the condition of having the subscribed column equal to TRUE. Let’s look at a few other common types of WHERE statements below.
account_id with any of the values 1,2,3, or 4. Imagine this scenario : users in our database can belong to many different organizations. We want to specifically contact users belonging to four of those organizations. So in our query, we can specify only those four account_ids using the IN keyword. When using IN, always be sure to include the values you are querying for in parentheses.
example.com domain. The LIKE keyword let’s us do just that. We provide the LIKE keyword with a basic pattern. In this case, that pattern is %@example.com. The % is called a wildcard operator. What this is saying is that we want all records where the email column matches the pattern of any character or set of characters followed by @example.com.
What if we wanted to match emails with from both example.com and example.net? We could include another wildcard:
@example.com and @example.net. It would also match with many email addresses we didn’t intend, like example-rama.com or examplecalifragilisticexpialidocious.gov. Instead, we can use the OR keyword to specify just these two domains.
AND keyword.
Using Your Data in Your Content
Let’s return to our original example:email, first_name, last_name and language fields, so how do we use them?
In our content, we can access those as user properties using the Liquid templating language.
Let’s say we want to look at the language and use a different greeting in our email depending on what that language is. In the greeting (in our email’s content), we’ll use the user’s first_name property to personalize the content.
That could look something like the following:
user object and the property names will match the fields from our SELECT statement in our SQL query.
We’re using Liquid’s IF statement to check the value of the language property, and then personalizing the content based on that result. Further, we access the user’s first_name using {{ user.first_name }} and print that in the email.

