You need to sign in to do that
Don't have an account?
8hrWait
IDs in IN clause not giving results
Hi,
Can anyone please let me know, how to retrieve database records using IDs in 'IN' clause for a query on a custom object.
The below query
select Id, Name from <customObject>__c gives all records
But, if a where clause is added to filter by Ids, no results are displayed.
For example,
select Id, Name from <customObject>__c where ID in (Set<String>) -> gives no results
Thx
Take this as :
Use Set as below :
Set<Id> test = New Set<Id> ();
List<customObject__c> Test2 = [select Id, Name from customObject__c where ID IN:test ];
All Answers
Take this as :
Use Set as below :
Set<Id> test = New Set<Id> ();
List<customObject__c> Test2 = [select Id, Name from customObject__c where ID IN:test ];
Use like this:
set<Id> setIds = new set<Id>();
for(Account objA :[select id,name from Account]){
setIds.add(objA.id);
}
List<Account> lstA = [select id,name from Account where ID IN : setIds];
Thank you for the solution.
I was using a custom query manager to exceute the query.For some reason, the code was not identifying the binding variable.
A direct call of Database.execute(query) worked.