select * from table_name where column like'&nbsp'

时间:2022-02-26 09:01:34

I need to find records containing html code such as '&nbsp' But when I try to run the select * from table_name where column like '&nbsp%' I got prompt asking for the value of nbsp. I guess the database thinks that nbsp is a parameter. I am wondering if the is an escape character so that I can tell the database that "&" is part of my query string. I tryed '\&nbsp' but didn't work.

我需要找到包含html代码的记录,例如' '但是当我尝试运行select * from table_name时,像' %'这样的列我会立即询问nbsp的值。我想数据库认为nbsp是一个参数。我想知道是否是一个转义字符,以便我可以告诉数据库“&”是我的查询字符串的一部分。我尝试'\ n'但是没有用。

My environment is Oracle 9i with sqlplus client.

我的环境是带有sqlplus客户端的Oracle 9i。

Thanks.

4 个解决方案

#1


11  

Have a look at this:

看看这个:

SQL Plus FAQ

SQL Plus常见问题

e.g.

SET ESCAPE '\'
SELECT '\&abc' FROM dual;

#2


11  

Easier way:

SET DEFINE OFF

设定定义

See: SET DEFINE

请参阅:SET DEFINE

#3


2  

The backslash should work, but I think you need to start your query with

反斜杠应该可以工作,但我认为你需要开始查询

SET ESCAPE ON

#4


0  

In PL/SQL, you would use:

在PL / SQL中,您将使用:

BEGIN select <Column> from <Table_name> into <Variable> where <Column> LIKE '\&nbsp\%' ESCAPE '\'; END /

BEGIN从 中选择 ,其中 LIKE'\  \%'ESCAPE'\';结束 /

Resources:

Wilcards in SQL on PSOUG.org

PSc在PSOUG.org上的Wilcards

LIKE Condition in Oracle® Database SQL Language Reference 11g Release 2 (11.2)

Oracle®数据库SQL语言参考11g第2版(11.2)中的LIKE条件

#1


11  

Have a look at this:

看看这个:

SQL Plus FAQ

SQL Plus常见问题

e.g.

SET ESCAPE '\'
SELECT '\&abc' FROM dual;

#2


11  

Easier way:

SET DEFINE OFF

设定定义

See: SET DEFINE

请参阅:SET DEFINE

#3


2  

The backslash should work, but I think you need to start your query with

反斜杠应该可以工作,但我认为你需要开始查询

SET ESCAPE ON

#4


0  

In PL/SQL, you would use:

在PL / SQL中,您将使用:

BEGIN select <Column> from <Table_name> into <Variable> where <Column> LIKE '\&nbsp\%' ESCAPE '\'; END /

BEGIN从 中选择 ,其中 LIKE'\  \%'ESCAPE'\';结束 /

Resources:

Wilcards in SQL on PSOUG.org

PSc在PSOUG.org上的Wilcards

LIKE Condition in Oracle® Database SQL Language Reference 11g Release 2 (11.2)

Oracle®数据库SQL语言参考11g第2版(11.2)中的LIKE条件