Home  >  Article  >  Database  >  How to use like query statement in oracle

How to use like query statement in oracle

WBOY
WBOYOriginal
2022-05-25 18:13:425974browse

In Oracle, the like statement is often used in conjunction with the where statement to retrieve the corresponding substring contained in a character field; this statement is mainly for character fields, and the syntax is "select * from table name where field name like corresponding value (substring)".

How to use like query statement in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How to use the like query statement in oracle

The syntax format of the like statement is:

select * from 表名 where 字段名 like 对应值(子串)

It is mainly for character fields, and its function is to Search the field column containing the corresponding substring.

We can use the like keyword in the where clause to achieve the effect of Oracle fuzzy query; in the where clause, we can use the Like keyword with wildcards for columns of datetime, char, and varchar field types. Fuzzy query,

The following are wildcard characters that can be used:

%: zero or more characters, there are three situations when using %

  • Field like ' Records where the %Keyword%' field contains "Keyword"

  • Field like Records where the 'Keyword%' field starts with "Keyword"

  • Records with fields like '% keyword' whose field ends with "keyword"

Example:

How to use like query statement in oracle

Single any Characters (underscores) are often used to limit the character length of expressions:

Example:

How to use like query statement in oracle

Characters within a certain range represent those listed in brackets One of the characters (similar to a regular expression). Specify a character, string, or range, requiring the matched object to be any one of them.

Example:

How to use like query statement in oracle

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to use like query statement in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn