在表中查找包含%符号的行[复制]

时间:2022-02-23 12:58:12

This question already has an answer here:

这个问题已经有了答案:

How to find rows that contains '%' symbol in a column of table.

如何在表的列中找到包含'%'符号的行。

For example, I have a column containing data as 'amylase 50% of dose'.

例如,我有一个列包含“50%剂量的淀粉酶”的数据。

How to select and filter all the rows containing % symbol in a given column?

如何选择和筛选给定列中包含%符号的所有行?

4 个解决方案

#1


3  

try this query

试试这个查询

select * from tablename where columnname like '%[%]%'

#2


2  

You can use WHERE Id LIKE '%[%]%'. An example will be something like this:

您可以使用“%[%]%”的Id。例如:

CREATE TABLE #Test
(
Id NVARCHAR(100)
)

INSERT INTO #Test VALUES ('100%'), ('1000')

SELECT * FROM #Test
WHERE Id LIKE '%[%]%'

DROP TABLE #Test

OUTPUT:

输出:

Id
100%

#3


1  

We use like clause/operator to find/match anything in columns. Below query will search '%' in starting/middle/ending or can say everywhere in a column value.

我们使用like子句/操作符查找/匹配列中的任何内容。下面的查询将在开始/中间/结束时搜索“%”,或者可以在列值中到处显示。

select * from tablename where columnname like '%[%]%'.

#4


0  

Try following,

尝试后,

select * from tablename where columnname like '%\%%'

#1


3  

try this query

试试这个查询

select * from tablename where columnname like '%[%]%'

#2


2  

You can use WHERE Id LIKE '%[%]%'. An example will be something like this:

您可以使用“%[%]%”的Id。例如:

CREATE TABLE #Test
(
Id NVARCHAR(100)
)

INSERT INTO #Test VALUES ('100%'), ('1000')

SELECT * FROM #Test
WHERE Id LIKE '%[%]%'

DROP TABLE #Test

OUTPUT:

输出:

Id
100%

#3


1  

We use like clause/operator to find/match anything in columns. Below query will search '%' in starting/middle/ending or can say everywhere in a column value.

我们使用like子句/操作符查找/匹配列中的任何内容。下面的查询将在开始/中间/结束时搜索“%”,或者可以在列值中到处显示。

select * from tablename where columnname like '%[%]%'.

#4


0  

Try following,

尝试后,

select * from tablename where columnname like '%\%%'