SOQL IN Operator in Salesforce

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

Brian is a software architect and technology leader living in Niagara Falls with 13+ years of development experience. He is passionate about automation, business process re-engineering, and building a better tomorrow.

Brian is a proud father of four: two boys, and two girls and has been happily married to Crystal for more than ten years. From time to time, Brian may post about his faith, his family, and definitely about technology.