Switch to: V11V10V9V8V7V6V5

Pattern Matching Check

It is checked whether the record value contained in the field match to the certain pattern. You can use LIKE instruction to do this. With the help of NOT LIKE you can find the records which don't match to the pattern. The pattern is the record which can contain one or more substitution character.

Substitution character % coincides with any chain of zero and more symbols. Substitution character _ (underline symbol) coincides with any separate symbol.

You can place substitution character in any place of pattern record and one record can contain several substitution characters.

With the help of LIKE instruction you can execute three types of record retrieval:

-- begins with...
 
SELECT company, credit_limit
FROM customers
WHERE company LIKE ' Smith% '
-- ends with...
 
SELECT company, credit_limit
FROM customers
WHERE company LIKE ' %th '
-- contains...
 
SELECT company, credit_limit
FROM customers
WHERE company LIKE ' %mith% '

While the records' pattern matching check it may occur that substitution characters are included to the symbol line as literals (designations). In such cases you can use the skip codes which are defined as a record containing one character in ESCAPE statement. '\' is default escaping character.

Find the goods whose codes begin with “\A%\B\C

SELECT order_num, product
FROM orders
WHERE product LIKE ' \\A\%\\B\\C% '
SELECT order_num, product
FROM orders
WHERE product LIKE ' \A$%\B\C% ' ESCAPE ' $ '

You can use LIKE instruction not only with the fields containing string data-type but also with numerical ones, the fields of date and time, that is to any ones which you can bring to string type. If the field contains NULL value, the check result will be NULL.