Your First Text Query
SELECT and FROM: the foundation
The simplest possible query:
SELECT email, firstname, lastname
FROM contact
This query returns the email, first name, and last name of all your HubSpot contacts. email, firstname, lastname are the technical HubSpot property names — the same ones visible in your portal settings.
Important: Property names are the HubSpot internal names (snake_case), not the labels displayed in the interface. For example, "Creation date" is written
createdate.
WHERE: filtering your results
To retrieve only contacts who are customers:
SELECT email, firstname, lastname
FROM contact
WHERE lifecyclestage = 'customer'
To add multiple conditions (all must be true):
SELECT email, firstname, lastname
FROM contact
WHERE lifecyclestage = 'customer'
AND createdate > '2024-01-01'
AND means both conditions must be satisfied simultaneously.
OR: one or the other condition
To retrieve customers OR recently created leads:
SELECT email, firstname
FROM contact
WHERE (lifecyclestage = 'customer')
OR (lifecyclestage = 'lead' AND createdate > '2024-01-01')
OR means it's enough for one of the two conditions to be true. Parentheses allow grouping conditions on each side of the OR.
Golden rule: The main
WHEREis evaluated directly by HubSpot. It's the most efficient way to filter — always prioritize this filter for criteria on the primary object.
Available HubSpot object types
| Object | Keyword |
|---|---|
| Contact | contact |
| Company | company |
| Deal | deal |
| Ticket | ticket |
| Custom objects | technical name of the object |