18.11.2011

Опция ESCAPE

Как использовать символы "%" и "_" в LIKE, когда нужны именно символы "%" и "_", а не шаблон.
You can include the actual characters "%" or "_" in the pattern by using the ESCAPE option.
The ESCAPE option identifies the escape character. If the escape character appears in the pattern
before the character "%" or "_" then Oracle interprets this character literally in the pattern,
rather than as a special pattern matching character.
Example:
To search for employees with the pattern 'A_B' in their name:
SELECT ename
FROM emp
WHERE ename LIKE '%A\_B%' ESCAPE '\';
The ESCAPE option identifies the backslash (\) as the escape character. In the pattern,
the escape character precedes the underscore (_). This causes Oracle to interpret the
underscore literally, rather than as a special pattern matching character.

Комментариев нет :