function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
paddybillipaddybilli 

Filter functionality using Like in soql

Hi,

 

How to filter records where customer type= M  in soql query. here i am getting all account records but i need filetring based on customer type. 

 

private List<Account> performSearch(string searchString) {
 
    String soql = 'select id, name from account where Customer_Type__c in ('M')';
    if(searchString != '' && searchString != null)
      soql = soql +  ' where name LIKE \'%' + searchString +'%\'';
   soql = soql +  ' where Customer_Type__c LIKE \'%' + searchString +'%\'';

    soql = soql + ' limit 25';
    System.debug(soql);
    return database.query(soql);
 
  }

 

Regards,

Billi

 

HariDineshHariDinesh

Hi,

 

Use this in starting:

 

String soql = 'select id, name from account where Customer_Type__c ='+'\''+'M'+'\'';