找到你要的答案

Q:How to find name start with '%' in sql

Q:如何找到的名字开始与“%”在SQL

I want to search name which start with '%' like '%smit' in oracle sql

i have tried with escape '%\%' but not able to find..

我想搜索的名字开始与“%”是“他”在Oracle的SQL

我已经尝试逃脱“%”,但无法找到..

answer1: 回答1:

You need to tell Oracle that you are using an escape character:

where name like '\%%' escape '\'

Anything in the search pattern after the character specified through the escape option will be treated "as is". So the above searches for any value that starts with the character %. The second % is again treated as a regular wildcard (because it's not prefixed with the escape character)

You can also choose a different escape character:

where name like '#%%' escape '#'

This is nothing Oracle specific, this is how the LIKE operator is defined in the SQL standard

您需要告诉Oracle您正在使用转义字符:

where name like '\%%' escape '\'

在搜索模式中的任何字符后,通过转义选项指定将被视为“是”。因此,上面搜索任何以字符%开头的值。第二%再处理为一个一般的通配符(因为它不是在前面加上转义字符)

您也可以选择一个不同的转义字符:

where name like '#%%' escape '#'

这是什么预言具体,这是怎样的操作是在SQL标准定义

oracle  oracle11g  oracle-sqldeveloper