You need to sign in to do that
Don't have an account?
SalesRed
How To Create A Set of IDs from a SOQL Retuned List Without First Traversing List?
Hello,
I've come across the following scenario.
- I use a SOQL statement to get a list of records.
- I need to use the ID's from this list for a second subsequent query.
Is there a way of getting all the ID's returned from the first query without looping through/travershing the result list first to get the ID's?
I don't wish to write a second query just to obtain the ID's but wondered could they alone be extracted from the first list without looping through the results?
Thanks for your help
You initialize the Map within the query
Map<ID, Lead> leadMap = new Map<ID, Lead>([SELECT Id, FirstName, LastName FROM Lead]);
Regards,
Satish Kumar
All Answers
You initialize the Map within the query
Map<ID, Lead> leadMap = new Map<ID, Lead>([SELECT Id, FirstName, LastName FROM Lead]);
Regards,
Satish Kumar
Thanks for your help!