Skip to content

The Soql.InnerQuery Class

Jason Siders edited this page Jun 29, 2025 · 8 revisions

Represents inner query logic, used for filtering results in a WHERE clause. Use this in conjunction with the addWhere SOQL method. For example:

SELECT Id 
FROM Account 
WHERE Id IN (
  SELECT AccountId 
  FROM Opportunity 
  WHERE IsWon = true
)
Soql.InnerQuery innerQuery = new Soql.InnerQuery(Opportunity.SObjectType)
  ?.addSelect(Opportunity.AccountId)
  ?.addWhere(Opportunity.IsWon, Soql.EQUALS, true)
  ?.toInnerQuery();
Soql soql = Database.Soql.newQuery(Account.SObjectType)
  ?.addWhere(Account.Id, Soql.IN_COLLECTION, innerQuery)
  ?.toSoql();

Constructors

  • InnerQuery(SObjectType objectType)

Methods

This class inherits the Soql.Builder's query building methods, documented here.

apex-database-layer

Home

Core Concepts

Reference Guide

Migration Guides

Clone this wiki locally