This course is currently a work in progress. Please join the waitlist to receive regular updates.

IN Operator in SOQL

The IN operator in SOQL is used to retrieve records that match multiple values in a field. It accepts a list of values, and the query returns records that match any value in the list.

SOQL queries can be executed from apex code, Visual studio code or in the Query Editor of the Developer Console.

Following is an example of finding the accounts where industry is 'Technology' or 'Finance' or 'Electronics'.

Loading...

In the above example:

  • The query statement starts with a SELECT keyword, followed by a set of comma-separated fields (e.g. id, Name) that you want to query from an object.
  • The FROM keyword specifies the object (e.g., Account) from which data is queried in Salesforce.
  • The records are filtered using the WHERE condition, with filters applied to the Industry field.
  • The IN operator is used to filter Account records where the Industry is either Technology, Finance, or Electronics.

Try It Yourself

Loading...

Hide this example

Try It Yourself

Loading...