subqueries related data

Data 360 Query Guide, mirrored from developer.salesforce.com: To check for the presence or absence of related data, use the `EXISTS` or `NOT EXISTS` operators. These operators are part of the `WHERE` clause that precedes a subquery. A subquery is a query that appears inside another query statement.

markdownreferencev1DAPQ-3GPMguide: data-cloud-query-guidestage: referencetrust: officialsource: developer.salesforce.comservice: data360interface: restinterface: sqlsubqueries related dataData 360Data CloudData 360 Query Guide

Created 23 Oct 2026 · Modified 23 Oct 2026 · 1 version

Mirror of <https://developer.salesforce.com/docs/data/data-cloud-query-guide/guide/subqueries-related-data.html> (Salesforce, Data 360 Query Guide), read 2026-10-23. Salesforce's own page is the authority; this copy exists because that site refuses non-browser readers.

To check for the presence or absence of related data, use the EXISTS or NOT EXISTS operators. These operators are part of the WHERE clause that precedes a subquery. A subquery is a query that appears inside another query statement.

These query examples all use a subquery to check on related records to accounts.

  • Which accounts don’t have a phone number?
  • Which accounts have a phone number but no email address?
  • How many accounts have a phone number but no email address?

For example, this query uses a subquery to return the accounts that don’t have a phone number.

This output shows the first few rows of the sample results.

ssot__Id__cssot__Name__c
001Hu00002xHZJnIAOPyramid Construction Inc.
001Hu00002xHZJtIAOUnited Oil & Gas, UK
001Hu00002xHZJuIAOUnited Oil & Gas, Singapore

You can use these predicates with subqueries.

  • EXISTS
  • NOT EXISTS
  • IN

Read this document as markdown — the same bytes an agent receives.