Reference Guide > TDV Support for SQL Operators > Condition Operators > LIKE
 
LIKE
The LIKE operator is used to match strings based on a pattern.
Syntax
column LIKE pattern [ESCAPE escape-character]
Remarks
The pattern string can contain wild-card characters that have special meaning:
% (percent sign). Matches any sequence of zero or more characters.
_ (underscore). Matches any single character.
Example (Like with Percent-Sign Match)
SELECT ProductID, ProductName, ProductDescription
FROM /shared/examples/ds_inventory/products products
WHERE ProductName LIKE 'Acme%'
 
The pattern matches Acme Memory, Acme Processor, and Acme Storage 40GB.
Example (Like with Underscore Match)
SELECT company, credit_limit
FROM customers
WHERE company LIKE 'Smiths_n'
 
The pattern matches Smithson and Smithsen, but not Smithsonian.
If the data value in the column is null, the LIKE test returns a NULL result.
You can locate strings that do not match a pattern by using NOT LIKE.
Example (Using The ESCAPE Character)
The ESCAPE character is used to match the wild-card characters themselves, as shown here.
SELECT order_num, product
FROM orders
WHERE product LIKE 'A$%BC%' ESCAPE '$'
 
The first percent sign is not treated as wild-card character, because it is preceded by the $ escape character.