问题
I using Salesforce (apex), I need to Query with a WHERE statement with toLowerCase ,i.e. I have a list (MyNames_list) with LowerCase values but the table values are not lowerCase.
In my Query when I check the Name in MyNames_list it will make toLowerCase value and then check it in the MyNames_list.
Something like this:
Name | LastName
BOBY | Testovich1
DANY | Testovich2
Ron | Testovich3
and in my list:
MyNames_list :boby,dany,ron
That still will return me all rows, because WHERE statement will check it with LowerCase.
//only example (not working code)
for(Users user:[SELECT Name,LastName FROM Users
WHERE ( Name.toLowerCase() IN : MyNames_list) ] )
{
//code....
}
Is there a way to do this in Salesforce (apex) Query ?
回答1:
Salesforce is only case-sensitive for fields that are explicitly case-sensitive (ie an external id that has been marked as case-sensitive)
The field you are querying, Name
is not case-sensitive - hence, you don't need to apply toLowerCase()
. You will get all matching fields anyway.
So your query could be:
for(User u:[SELECT Name,LastName FROM User WHERE Name IN :MyNames_list)]){
//code....
}
来源:https://stackoverflow.com/questions/39557852/salesforceapex-query-select-with-where-tolowercase