Semi-Join and Anti-Join Filters

A semi-join is a subquery on another object in an in clause that restricts the records returned by the primary query. Contrastingly, an anti-join is a subquery on another object in a nin clause that restricts the records returned.

Filtering by an ID field enables you to create parent-to-child semi-joins and anti-join, such as Account to Contact or Account to Opportunity.

Filtering by a reference field is currently not supported.

The inq filter type for the ID field enables you to restrict the records returned by the primary query. To create a semi-join filter, use the inq filter type like this.

The previous query is translated to the following SOQL statement.

The ninq filter type for the ID field enables you to restrict the records returned by the primary query. To create a semi-join filter, use the ninq filter type like this.

The previous query is translated to the following SOQL statement.

SOQL and SOSL Reference: Semi-Joins with IN and Anti-Joins with NOT IN