Skip to main content

JoinQuery

Construct join-query and use it in condition.

Methods

The following are methods for FilterGroup.

INIT

SELECT

WHERE

INIT

of

Conctructs an JoinQuery.

Signature

static JoinQuery of(SObjectType ofObject)

Example

SELECT Id
FROM Account
WHERE Id IN (
SELECT AccountId
FROM Contact
WHERE Name = 'My Contact'
)
SOQL.of(Account.SObjectType)
.whereAre(SOQL.Filter.with(Account.Id).isIn(
SOQL.InnerJoin.of(Contact.SObjectType)
.with(Contact.AccountId)
)).toList();

SELECT

with

SELECT statement that specifies the fields to query.

Signature

static JoinQuery with(SObjectField field)

Example

SELECT Id
FROM Account
WHERE Id IN (
SELECT AccountId
FROM Contact
)
SOQL.of(Account.SObjectType)
.whereAre(SOQL.Filter.with(Account.Id).isIn(
SOQL.InnerJoin.of(Contact.SObjectType)
.with(Contact.AccountId)
)).toList();

WHERE

whereAre

The condition expression in a WHERE clause of a SOQL query includes one or more field expressions. You can specify multiple field expressions in a condition expression by using logical operators.

For more details check SOQL.FilterGroup and SOQL.Filter

Signature

static JoinQuery whereAre(FilterGroup conditions)

Example

SELECT Id
FROM Account
WHERE Id IN (
SELECT AccountId
FROM Contact
WHERE Name = 'My Contact'
)
SOQL.of(Account.SObjectType)
.whereAre(SOQL.Filter.with(Account.Id).isIn(
SOQL.InnerJoin.of(Contact.SObjectType)
.with(Contact.AccountId)
.whereAre(SOQL.Filter.with(Contact.Name).equal('My Contact'))
)).toList();