Skip to main content

Posts

Showing posts with the label Like Operator in Soql

LIKE Operator In Salesforce

The LIKE operator in SOQL and SOSL is quite similar to the LIKE operator in SQL; it provides a mechanism for matching partial text strings and includes support for wildcards. Suppose we need to delete some test records of Account object, all test records are created having account name is test. Account name may "testasish" or "accounttest", how can we get those record by Soql query ? For this propose LIKE operator is useful. For example  List<Account> listOfAccounts; listOfAccounts = [SELECT id, Name                            FROM Account                            WHERE Name   LIKE '% test% ' ]; This query matches both testasish,accounttest, and test. Use Cases Of LIKE Operator The % and _ wildcards are supported for the LIKE operator. The % wildcard matches zero or more characters. The _ wildcard matches exactly ...