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
sonamsonam 

Soql with two in clause

I have to query from a custom object.

In the apex class i have to pass two lists as given below:

 

Select  field1__c,field2__c ,  ,field3__c,field4__c,field5__c,field6__c,field7__c
From Object_custom__c where
field1__c in : List1 AND 
field6__c in : List6

 

When I run the following query in developer console but it gives 'Unknown error parsing query'.

 

Select  field1__c,field2__c ,  ,field3__c,field4__c,field5__c,field6__c,field7__c
From Object_custom__c where
field1__c in : ['Field1_value1,' Field1_value2'] AND 
field6__c in : ['Field6_value1,' Field6_value2']

 

 

ManojjenaManojjena

Here you are comparing with one field with a list of field using IN operator.
Do one thing create two List of of type of the data type of the field which you are comparing. Iterate two list with help of for loop.

add the field in set or list ,then compair those list or Set with IN operator.

 

 

PremanathPremanath
I think you can do it Direct way using query only...
You should check the query once, might be some other problem you have,
Use Debug Logs/Developer Console to track that Error

prem