Home > Database > Oracle > body text

Instr usage in oracle

下次还敢
Release: 2024-05-02 23:54:57
Original
972 people have browsed it

The INSTR function in Oracle is to find the starting position of a substring in a string. The syntax is INSTR(string, substring, [start_position]). It returns the starting position of the matching substring. Find If not, return 0. Among them, string is the string to be searched, substring is the substring to be found, and start_position is the starting position of the search (optional). The INSTR function is not case-sensitive. By default, it searches from the beginning of the string. It supports searching from the specified position. If the substring appears multiple times in the string, only the starting position of the first matching item will be returned. If the string or subword

Instr usage in oracle

INSTR usage in Oracle

The INSTR function is used in Oracle to find substrings in a string. starting point. It returns the starting position of the matched substring, or 0 if no match is found.

Syntax:

<code>INSTR(string, substring, [start_position])</code>
Copy after login

Parameters:

  • string: The string to search for.
  • substring: The substring to be found.
  • start_position: Start searching from the specified position in the string (optional).

Usage:

The INSTR function can be used to find whether another string exists in a string and return the starting position of the match. For example:

<code>SELECT INSTR('Hello World', 'World') FROM dual;</code>
Copy after login

Output:

<code>7</code>
Copy after login

This means that the substring "World" starts at the 7th character of the string "Hello World".

Optional parameters:

The start_position parameter allows you to specify a specific position in the string to start the search from. For example, to search starting at character 5:

<code>SELECT INSTR('Hello World', 'World', 5) FROM dual;</code>
Copy after login

Output:

<code>0</code>
Copy after login

This means that in the string "Hello World", there is no match starting at character 5.

Note:

  • The INSTR function is not case-sensitive.
  • If start_position is not specified, the search starts from the beginning of the string by default.
  • If the substring appears multiple times in the string, the INSTR function only returns the starting position of the first match.
  • The INSTR function returns 0 if the string or substring is empty.

The above is the detailed content of Instr usage in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!