Back

How to Use SmartConnect CRM Query Builder

Published: Oct 21, 2025
Post Author Written by Maksudul Haq

With SmartConnect CRM Query Builder, you can join tables, filter data, and more. Jump to a specific section or scroll through to read about common uses for SmartConnect Query Builder, and how you can troubleshoot common issues.

Table of Contents

Adding and Joining Tables

Step 1: Create a Bulk Query

  1. Navigate to Data Source and then select Bulk Sources.
  2. Click on Query and then select Create Bulk Query.
  3. Choose the CRM connector.
  4. Enter a name for your query.
  5. Select the Connection and Organization.
  6. Click the Validate button.
  7. Once validation is complete, the Edit Query button will be enabled.

Step 2: Build Your Query

  1. Click on Edit Query.
  2. In the Filter box, type in the table name (e.g., “Contact”).
  3. Select the table and drag it into the workspace.
  4. Repeat this process to add multiple tables as needed.

Step 3: Joining Tables

  • Tables can be joined using column references.
  • Example: To join the Contact table with the Account table:
    • Select the Account field in the Account table.
    • Drag and connect it to the Account field in the Contact table.
    • By default, this creates an inner join between the tables.

Step 4: Modifying Joins in CRM Query Builder

  1. Right-click on the relationship line in the CRM Query Builder.
  2. Select either the Left Join or Right Join checkbox to modify the join type.

Filtering Data

Although the CRM Query Builder doesn’t offer all the flexibility of SQL, you can still achieve similar results. Below are some common filtering examples and issues users encounter.

When building queries in SmartConnect’s CRM Query Builder, you can use the following Comparison operators – Example Scenario :

Note: The “Not Equal To” ( < > ) condition does not work.

  • CRM FetchXML does not support <> as a “not equal to” operator.
  • Instead, use !=.
  • Your query should be formatted as follows:

Logical operator AND – Example Scenario :

OperatorDescriptionExample
ANDALL conditions must be trueAccount.Name = 'Metus Co Test' AND Account.Createdon >= '2021-11-12' AND Account.Status = 1

AND operator in SmartConnect Query Builder:

OR operator – Example Scenario:

OperatorDescriptionExample
ORAny one condition must be trueAccount.Name = 'Metus Co Test' OR Account.Name = ‘Metus Co Test’ OR Status = 1

Translated in SmartConnect Query Builder:

String Operators – Example Scenario :

OperatorDescriptionExample
likeContains a value (wildcard search)name LIKE '%School%'
not-likeDoes not contain a valuename NOT LIKE '%School%'

Translated in SmartConnect Query Builder:

Null Value Operators – Example Scenario:

OperatorDescriptionExample
nullValue is nullemail IS NULL
not-nullValue is not nullemail IS NOT NULL

SmartConnect Query Builder:

Date Operators – Example Scenario:

OperatorDescriptionExample
yesterdayMatches records from yesterdaycreatedon = YESTERDAY
todayMatches records from todaycreatedon = TODAY
tomorrowMatches records from tomorrowcreatedon = TOMORROW
last-x-daysMatches records within the last X dayscreatedon LAST 30 DAYS
next-x-daysMatches records within the next X dayscreatedon NEXT 7 DAYS

Note The YESTERDAY, TODAY, LAST 30 DAYS, NEXT 7 DAYS Conditions do not work.

Output responses

Using Joins to Retrieve Data from Related Tables.

Example Scenario:

I need a data source with all active customers and prospects including the primary contact and the parent account.

  1. Account Table (stores company information)

Each Contact belongs to an Account, and both tables share a common field (accountid), which establishes the relationship.

This Join SmartConnect Query Builder:

This will create an SQL Query Using INNER The following SQL query retrieves the Account Name, City from the Contact Address, and the Account Creation Date, but only for contacts where the city is specified.

Select Account.Account,
  Account.[Account Name],
  Account.[account number],
  Account.Status,
  ParentAccount.[Account Name] As name1,
  PrimaryContact.[Full Name],
  PrimaryContact.Email,
  Account.[Relationship Type]
From Account
  Inner Join Contact PrimaryContact On Account.[Primary Contact] =
    PrimaryContact.Contact
  Inner Join Account ParentAccount On Account.[Parent Account] =
    ParentAccount.Account
Where (Account.Status = 'Active' And Account.[Relationship Type] = 3) Or
  (Account.Status = 'Active' And Account.[Relationship Type] = 8)

Tip: If joining the same table multiple times, use table aliases to make them easier to work with. In the above ParentAccount is the Alias of the join to the Account Table.

To set a Table Alias: Click on Table Settings, then enter the desired Alias.

Limitations with CRM FetchXml

When using the SmartConnect CRM Query Builder, there are several limitations to keep in mind.

  • No Aggregation Support
    • Functions like SUM(), AVG(), COUNT(), or MAX() are not available.
  • No Column Aliases
    • You can use table aliases, but column aliases are not supported.
  • Limit of 9 Tables per Query
    • The query cannot include more than 9 joined tables.
  • No RIGHT OUTER JOIN Support
    • Only INNER JOIN and LEFT OUTER JOIN are supported.
  • No Support for UNION Queries
    • Combining results from multiple queries using UNION or UNION ALL is not possible.
  • Cannot Add Local Constants
    • Fixed constant values cannot be added directly into the query.
  • No Relative Date Filters
    • Filters like LastNdays are not supported; instead, you must use a Global Variable.

This help article can help you get started using Global Variables to handle date filters dynamically.

By understanding these limitations, you can optimize your queries and find alternative solutions when needed.

Optimize Performance

To improve query efficiency and execution speed, follow these best practices:

  • Select Only Necessary Columns
    • Avoid selecting * (all columns). Instead, include only the columns required for the integration.
  • Use INNER JOINs When Possible
    • INNER JOINs are generally more efficient than LEFT OUTER JOINs, as they reduce the dataset size by filtering unmatched records early.

By applying these optimizations, you can enhance query performance and reduce processing time.

Troubleshooting

If you encounter issues while using the SmartConnect CRM Query Builder, consider the following troubleshooting steps:

Query Runs Slowly

  • Select only the necessary columns instead of using * ALL.
  • Use INNER JOINs when possible instead of LEFT OUTER JOINs to reduce unnecessary data processing.
  • Limit the number of tables in the query (SmartConnect supports up to 9).

Filtering Issues

  • If <> (not equal to) doesn’t work, use != instead.
  • CRM Query Builder does not support relative date filters like LastNdays. Use Global Variables instead.

Multiple OR Conditions Not Grouping Correctly

  • Ensure OR conditions are enclosed in parentheses to apply the correct logic.
Or with Groupby

Also, see our help article on Using multiple ‘Or’ statements are not being grouped correctly.

Feeling stuck? Get the support and guidance you need to help you power through any data challenge

We're on your integration team. Connect with our people and let us know how we can help you.