Salesforce(apex) Query select with Where toLowerCase [英] Salesforce(apex) Query select with Where toLowerCase
问题描述
我使用 Salesforce (apex),我需要使用带有 toLowerCase 的 WHERE 语句进行查询,即我有一个带有小写值的列表 (MyNames_list),但表值不是小写.
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.
在我的查询中,当我检查 MyNames_list 中的 Name 时,它将生成 toLowerCase 值,然后在 MyNames_list 中检查它.
In my Query when I check the Name in MyNames_list it will make toLowerCase value and then check it in the MyNames_list.
像这样:
Name | LastName
BOBY | Testovich1
DANY | Testovich2
Ron | Testovich3
在我的列表中:
MyNames_list :boby,dany,ron
MyNames_list :boby,dany,ron
那仍然会返回我所有的行,因为 WHERE 语句会用小写检查它.
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....
}
有没有办法在 Salesforce (apex) 查询中做到这一点?
Is there a way to do this in Salesforce (apex) Query ?
推荐答案
Salesforce 仅对明确区分大小写的字段(即已标记为区分大小写的外部 ID)区分大小写
Salesforce is only case-sensitive for fields that are explicitly case-sensitive (ie an external id that has been marked as case-sensitive)
您查询的字段,Name
不区分大小写 - 因此,您不需要应用 toLowerCase()
.无论如何,您将获得所有匹配的字段.
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.
所以您的查询可能是:
for(User u:[SELECT Name,LastName FROM User WHERE Name IN :MyNames_list)]){
//code....
}
这篇关于Salesforce(apex) Query select with Where toLowerCase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!