+ Start a Discussion
PlainviewPlainview 

Need to make a query selective.

I am new to Apex and need to add an index filter.

The query in question:

"List<Account> leadAccountIds=Select Id, OwnerId, Name FROM Account WHERE Name IN: companies;"

Seeking some syntax advice.

Thanks!
 
RamuRamu (Salesforce Developers) 
the below article might help

https://help.salesforce.com/apex/HTViewSolution?urlname=How-can-I-make-my-SOQL-query-selective-And-the-process-to-determine-the-fields-that-can-be-custom-indexed&language=en_US
Sumitkumar_ShingaviSumitkumar_Shingavi
It should be
List<Account> lAccountIds = [Select Id, OwnerId, Name FROM Account WHERE Name IN :companies];
and "companies" might be
Set<String> companies = new Set<String>();

 
Vikash TiwaryVikash Tiwary
List<Account> leadAccountIds = [Select Id, OwnerId, Name FROM Account WHERE Name IN: companies];

Thanks