Oracle fuzzy query does not include the implementation of a string

Source: Internet
Author: User

To meet this requirement, the query number ends with 11 and cannot contain "4" from the fourth to the eighth digit. It was initially assumed that Oracle and SQL server support the same [^ 4], if I have checked a lot on the internet, it also means that it is supported. I have no effect on using it. The instr and substr functions are used to solve the problem.

Instr (string1, string2 [, start_position [, nth_appearance]): retrieves the index of the string in the specified string.

Parameter Analysis:

String1

Source string to be searched in this string.

String2

The string to be searched in string1.

Start_position

Position of string1. This parameter is optional. If omitted, the default value is 1. The string index starts from 1. If this parameter is positive, it is retrieved from left to right. If this parameter is negative, from right to left, the start index of the string to be searched in the source string is returned.

Nth_appearance

This parameter is optional. If omitted, the default value is 1. If it is negative, an error is returned.

If 0 is not found during search, the index of the searched string is returned.

Substr (string, start_position [, length]): gets the string with the specified start position and length in the string.

Parameter Analysis:

String

Source string, which must be truncated.

Start_position

The start position of the string.

Length

To intercept the string from the starting position to the end of the specified length.

The statement is actually very simple:

Select count (*) from tb_name where no like '% 11' and instr (substr (no, 4, 5), '4') <> 0

In this way, you can.

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.