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
nitin Sharma 401nitin Sharma 401 

Batch Apex and issue about querying contact object

Can somebody please tell me how to write a below given query in batach apex which I have writte in start method and then sent them to the execute method.

However ,My problem is I am not able to write where clause

string query='SELECT ID,Ownerid,Accountid,prestigious_contact__c from contact where assistantname='Christy'' && level__c='Primary' && prestigious_contact__c';

This  query is for the Batch Apex class.
1)Assistantname field is text
2) level__c is a picklist field
3)prestigious_contact__c is  a boolean field which is checkbox on the contact object


 
Suraj MakandarSuraj Makandar
Hi Nitin

Please find updated query below:
String query='SELECT ID,Ownerid,Accountid,prestigious_contact__c FROM contact WHERE assistantname=\'Christy\'  AND  level__c=\'Primary\' AND  prestigious_contact__c=True';


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Suraj
nitin Sharma 401nitin Sharma 401
Thanks Suraj,

That was nicely done by you..However,I need some explanation for my understanding...I saw that you have replaced "&&" with "And " so please tell me what is the the difference between them and  where one should "And" intead of" &&"...At times in trigger I have used && and it works but in the batch apex it became a problem..

Secondly,what's with those back slash etc..Is there some info or link that can help me in understanding that type of syntax   
sachinarorasfsachinarorasf
Hi Nitin,

I have gone through your problem can please try this.
 
string query='SELECT ID,Ownerid,Accountid,prestigious_contact__c from contact where assistantname=\'Christy\' and level__c\'Primary\' and prestigious_contact__c= true';

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora