SOQL IN Operator in Salesforce

Salesforce Logo

Sharing is Caring

When writing SOQL queries we can use the IN operator or the = operator as long as we are using variables instead of hardcoded strings. This works because the result will be identical.

For example, in this code snippet we’re using the IN operator with a set of Strings (hardcoded Account Id’s from a dev org)

Which then results in the following:

If we use the = operator we get the exact same results.

I prefer to use the IN operator because I find it more legible and semantically correct.

Also published on Medium.

Sharing is Caring