LIKE

LIKE, MATCHES, MATCHING

Top  Previous  Next

 

The LIKE selection clause operator compares a field or evaluated expression against another field, evaluated expression or literal value and tests for the first item matching the pattern template given by the second. The synonyms LIKE, MATCHES and MATCHING can be used.

 

 

Format

 

field LIKE {NO.CASE} template

 

where

 

fieldis the first field or evaluated expression to be compared.

 

templateis the field, evaluated expression or literal value representing the pattern against which field is to be compared. The optional NO.CASE qualifier causes a case insensitive comparison to be applied.

 

 

The LIKE selection clause operator returns True if field matches template.

 

The LIKE operator treats characters that do not correspond to any valid component of a pattern as literal values which must be matched exactly. Thus it is possible to find all the QMBasic include records (which have a suffix of .H) in the BP file by a command of the form

 

SELECT BP WITH @ID LIKE ....H

 

The initial three dots are a valid template component. The remaining two characters are not and are hence treated as literals. It would be better to enter this as

 

SELECT BP WITH @ID LIKE "...'.H'"

 

to avoid confusion. In some cases quotes must be used to handle literal values which are also valid components of a pattern template.

 

 

Example

 

LIST STOCK WITH PRODUCT.CODE LIKE A...

 

This command lists items found on the STOCK file with a PRODUCT.CODE starting with A.

 

 

See also:

Pattern Matching