JoinQuery
Construct join-query and use it in condition.
Methods
The following are methods for FilterGroup.
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
SELECTstatement 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
WHEREclause 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();