您的位置:首页 > 数据库 > Oracle

Oracle中like查询下划线等特殊字符的处理

2013-09-28 15:40 447 查看
You can include the actual characters "%" or "_" in the pattern by using the
ESCAPE
clause, which 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.

To search for employees with the pattern 'A_B' in their name:

SELECT last_name


FROM employees


WHERE last_name LIKE '%A\_B%' ESCAPE '\';



The
ESCAPE
clause 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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: