BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
90 / 278 · Module 5 — Salesforce Data Model + SOQL · filtered: code← prev⊞ allnext →

5.27Semi-joins

Suppose we want Accounts that have Contacts meeting a condition.

Conceptually:

SELECT Id, Name
FROM Account
WHERE Id IN (
    SELECT AccountId
    FROM Contact
    WHERE Email LIKE '%@acme.com'
)

That's a semi-join style query.

Salesforce documentation also uses semi-join patterns to filter objects based on related records.

Useful for:

Accounts with Contacts
Accounts with Opportunities
Accounts with Cases

matching criteria.