SQL/MP Reference Manual
HP NonStop SQL/MP Reference Manual—523352-013
L-5
Examples—LIKE
Suppose that you want to select all names that end with the letter y. If you
define the pattern-matching string as “%y@,” this statement finds all names
ending in y (provided that no trailing blanks are entered):
>> SELECT NAME FROM EMPLOYEE
+> WHERE NAME LIKE "%y@"
+> TERMINATE "@";
NAME
----
Jay
Holly
The character sets associated with the column, the LIKE pattern, the ESCAPE
character, and the TERMINATE character must be the same.
When two-character strings are considered equivalent to one-character strings,
LIKE might not return the expected result. For example, if a-umlaut is considered
equal to ae, LIKE a% does not return a match on string a-umlaut.
Examples—LIKE
This LIKE predicate finds all employee names beginning with ZB:
EMPNAME LIKE "ZB%"
This LIKE predicate finds all job titles that match a specific string provided at
execution time:
JOB LIKE ?SOMEJOB
This LIKE predicate finds all part descriptions that are not FLOPPY_DISK. The
escape character indicates that the backslash in “FLOPPY_DISK” is part of the
string to search for, not a wild-card character.
PARTDESC NOT LIKE "FLOPPY\_DISK" ESCAPE "\"
This LIKE predicate specifies that the column NAME is associated with the
ISO88591 character set. The predicate finds the value A_B:
NAME LIKE _ISO88591"A\_B" ESCAPE _ISO88591"\"