You need to sign in to do that
Don't have an account?
Kaplan Elad
SOQL Query to look for field contains value
I have a text field on Account, which hold domains spereated with semi colon ( e.g: gmail.com,aol.com,hotmail.com).
I want to retreive all the Accounts, where this field contains specific domain (e.g: gmail.com).
Can I do it?
I want to retreive all the Accounts, where this field contains specific domain (e.g: gmail.com).
Can I do it?
You may use "like" keyword in your SOQL with "%" to process the comparison as "contains". For example, SELECT Id FROM Account WHERE Domains LIKE '%gmail.com%'
This will work only when the domain is the same, but when it's a variable, it will not compile (
Domains LIKE '%domain%'
)
I succeeded using dynamic Query :
String soql = 'select Id, RW_Domain__c FROM Account WHERE RW_Domain__c LIKE \'%'+ domainName +'%\'' ;
Nevertheless, we could do it through inline SOQL as well, see below code: