Previous Topic: CONTAINS

Next Topic: Use the Results of a Previous &NDBSCAN

LIKE

The LIKE operator allows pattern matching to be performed. The NOT LIKE operation does the same, but matches records without the pattern.

The argument string for LIKE can contain any characters except for two special characters: _ (underscore) and % (percent). These characters only match themselves (the CAPS=NO/SEARCH rules are honored).

The special characters obey the following rules:

These special characters can be used as many times as required in a search string. Some examples follow:

ABC

Matches only records with ABC in the field.

ABC%

Matches on values starting with ABC

ABC_%

As above, but at least one character must follow ABC

%XYZ

Matches fields ending in XYZ

%mmm%

Matches fields with mmm somewhere in them

%FRED%_%BLOGGS%

Matches a field containing the strings FRED and BLOGGS in that order, with at least one character between them

_ _ _

Matches a field exactly 3 characters long

_ _XY_%

Matches a field at least 5 characters long, with XY in columns 3 and 4

It is evident that LIKE is a powerful operator and consequently can use significant CPU resources.

The first two examples in this table can also be done using keys. LIKE attempts to use keys to fully or partially (whenever a LIKE argument has non-special leading characters) determine matching records.