SOQL Query Where Id "In" Versus "Equals"(=)

I've not seen a difference functionally; I strongly prefer using IN as that is what would be required in SQL, and it it more accurate, and more descriptive.

First_Name__c is not logically equal to a list.

Using the syntax First_Name___c IN :names makes it clear that names is a collection, and that the developer knows that it's a collection


They are functionally equivalent. I agree with Mike that IN is more syntactically clear, but either one works.

See also: How to find out if an Object is a collection or single value?

This equivalence can be quite useful when building dynamic SOQL.

Tags:

Soql

Apex