且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Oracle SQL查询中使用字符串包含功能

更新时间:2022-12-04 20:27:00

通过我假设您是说表person中的行.您正在寻找的是:

By lines I assume you mean rows in the table person. What you're looking for is:

select p.name
from   person p
where  p.name LIKE '%A%'; --contains the character 'A'

以上是区分大小写的.对于不区分大小写的搜索,您可以执行以下操作:

The above is case sensitive. For a case insensitive search, you can do:

select p.name
from   person p
where  UPPER(p.name) LIKE '%A%'; --contains the character 'A' or 'a'

对于特殊字符,您可以执行以下操作:

For the special character, you can do:

select p.name
from   person p
where  p.name LIKE '%'||chr(8211)||'%'; --contains the character chr(8211)

LIKE运算符匹配一个模式. Oracle文档中详细描述了此命令的语法.您通常会使用%符号,因为这意味着匹配零个或多个字符.

The LIKE operator matches a pattern. The syntax of this command is described in detail in the Oracle documentation. You will mostly use the % sign as it means match zero or more characters.