Using STARTING WITH

From InterBase
Jump to: navigation, search

Go Up to Using Comparison Operators in Expressions


STARTING WITH is a case-sensitive operator that tests a string value to see if it begins with a stipulated string of characters. To support international character set conversions, STARTING WITH follows byte-matching rules for the specified collation order. The complete syntax for STARTING WITH is:

<value> [NOT] STARTING WITH <value>

For example, the following cursor retrieves employee last names that start with “To”:

EXEC SQL
DECLARE TO_EMP CURSOR FOR
SELECT LAST_NAME, FIRST_NAME
FROM EMPLOYEE
WHERE LAST_NAME STARTING WITH 'To';

Use NOT STARTING WITH to retrieve information for columns that do not begin with the stipulated string. For example, the following cursor retrieves all employees except those whose last names start with “To”:

EXEC SQL
DECLARE NOT_TO_EMP CURSOR FOR
SELECT LAST_NAME, FIRST_NAME
FROM EMPLOYEE
WHERE LAST_NAME NOT STARTING WITH 'To';

For more information about collation order and byte-matching rules, see the Data Definition Guide.

Advance To: