You need to sign in to do that
Don't have an account?
UdayWagle20
SOQL does not return results in the same order of list used in IN: clause
Hi All,
Here I have list of account Ids.
List<Id> accIds= new List<Id>()
List<Contact> conList = [SELECT Id,Name WHERE accountId IN :accIds];
Now in the above conList I want to query the contacts in same order as the ids in the account.
currently what is happening is if accIds list contain {1,2,3}, contacts are returned in the order {2,1,3}
I want them to be in the same order.
How do I achive this ? Please help me to resolve the above issue.
Can you try using the ORDER BY on a field and see if it works?
Regards,
Anutej
Thanks for the reply Anutej.
I have tried it, it won't work for my usecase. Want to know how it can be done for the above use case with the list of ids in the IN: clause.
Regards,
Uday