SOQL Like Operator

LIKE provides a mechanism for matching partial text strings and includes support for wildcards. % is used as a wildcard to match zero or more characters and _ must match exactly one character. The example will return all emails that have force.com and salesforce.com.

For example, the following query matches vetforce, salesforce, salesforce.com

SELECT FirstName, LastName, Email FROM Contact WHERE Email LIKE ‘%force%’

The following query matches force.com, but not salesforce or vetforce

SELECT FirstName, LastName, Email FROM Contact WHERE Email LIKE ‘force%’

The following query matches salesforce or vetforce but not force.com

SELECT FirstName, LastName, Email FROM Contact WHERE Email LIKE ‘%force’

Starting with text ‘force’ : ‘force%‘

Ending with text ‘force’ : ‘%force’

Contains text ‘force’ : ‘%force%‘

Starting with ‘force’ and Ending with ‘xyz’ : ‘force%xyz’

https://d259t2jj6zp7qm.cloudfront.net/images/v1517602081-Db-query-search-optimization-cheat-sheet_mb2qaz.pdf

Post a Comment

0 Comments