Salesforce(apex)查询选择“在哪里放下" [英] Salesforce(apex) Query select with Where toLowerCase

查看:90
本文介绍了Salesforce(apex)查询选择“在哪里放下"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Salesforce(apex),我需要使用带有toLowerCase的WHERE语句进行查询,即我有一个带有LowerCase值的列表(MyNames_list),但是表值不是lowerCase.

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语句将使用LowerCase对其进行检查.

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)查询选择“在哪里放下"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆