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
harita boyinaharita boyina 

in how many ways we write soql quries in apex

in how many ways we write soql quries in apex
can get the answer immediately
naga1.392970850770172E12naga1.392970850770172E12
Hi Harita ,

Example 1

SELECT Id FROM Contact WHERE Id In ('00Q6000000nuyL2EAI','00Q6000000iyBBhEAM','00Q6000000j007MEAQ')

Example 2

SELECT Id FROM Lead WHERE Email != ' '

This one is a trick. Email is an indexed field on Lead but if you look at my WHERE clause, this is going to return darn near all the Leads. So, I didn't reduce this record set by much and thus this reverts to a 'non-selective' query.

SELECT Id FROM Lead WHERE Email != ' ' and Status = 'Open' and OwnerId in  ('005d0000001btXoAAI', '005d0000002X1AqAAK')

Go through this once u can get an idea-https://developer.salesforce.com/page/A_Deeper_look_at_SOQL_and_Relationship_Queries_on_Force.com
 
praveen murugesanpraveen murugesan
Hi,

Refer this links,

https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_variables.htm
http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL.htm
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dynamic_soql.htm

Thanks