Comparison between Charindex and Instr in Oracle in SQL

Source: Internet
Author: User

SQL: charindex ('string', field)> 0 charindex ('admin', MUserID)> 0

Oracle: instr (field, 'string',)> 0 instr (MUserID, 'admin',)> 0

The Instr function in Oracle is used in the project. By the way, I learned this knowledge carefully.

In Oracle, you can use the Instr function to determine whether a string contains specified characters.

Its syntax is:
Instr (string, substring, position, occurrence)
Where

String: indicates the source string;

Substring: represents the substring to be searched in the intelligent source string;

Position: indicates the start position of the search. this parameter is optional. The default value is 1;

Occurrence: specifies the number of substrings that appear from the source character list. This parameter is optional. The default value is 1;
If the position value is negative, it indicates searching from right to left.
Return Value: the position of the searched string.

For Instr functions, we often use this method to find the position of the specified substring from a string.

For example:

SELECT Instr ('Hello word', 'O',-1, 1) "String" FROM Dual:

Instring
----
8

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.