Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

What is a SOQL like query?

Asked by Alan Taylor Sep 23, 2022 1.4K views 1 answer
Share

About this question

I am trying to make a query that will search for accounts with a name similar or exactly matching a field value.


So for example I have "Sales-Force" in the field. There is an account called "Salesforce" or "Sales Force"


My current query


Select Id, Name FROM Account WHERE Name LIKE '%Sales-Force%'
This isn't returning my accounts named "Sales Force" or "Salesforce" in my query editor.


UPDATED * My Apex code


string accountName= record.Name;
    if(accountName.contains('-'))
    {
        accountName = accountName.replace('-', '%');
    }
    if(accountName.contains(' '))
    {
        accountName = accountName.replace(' ', '%');
    }
    accountName= '%' + accountName+ '%';
List accountLookup = new List();
accountLookup = [Select Id, Name FROM Account WHERE Name LIKE :accountName];


Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.