function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NoodleNoodle 

SOQL query with OR for picklist field

I have a trigger on a Parent Object_A to update records on a Child Object_B 

I have a Set<ID> myID to get current record from Object A.

Object_B has a Picklist field Status__c.

List<Object_B> ToUpdate = [SELECT id, Name, Status__c from Object_B WHERE Status__c = 'Open' OR Status__c = 'Late' AND Object_B.Object_A in ;myID];

I would like to choose records that have the picklist value of EITHER Open or Late and where the lookup for Object A has the ID from my set myId.
It all works perfectly if I do Where Status equals one value. But I can't figure out how to say one value or the other.

Thanks in advance
Rufus RodenRufus Roden

Probably the easiest solution is to add in braces
List<Object_B> ToUpdate = [SELECT id, Name, Status__c from Object_B WHERE (Status__c = 'Open' OR Status__c = 'Late') AND Object_B.Object_A in :myID];

 
yeshabyeshab
List<Object_B> ToUpdate = [SELECT id, Name, Status__c from Object_B WHERE Status__c  IN ( 'Open' , 'Late') AND Object_B.Object_A in :myID];