How to filter the central score of an SQL string field

Source: Internet
Author: User
What should I do if I need to filter the scores in the middle of an SQL string field? The following describes how to filter records of the central score of an SQL string field for your reference. For example, there is a KKBH (bayonet number) field, which is a dictionary field (corresponding to the number field of another entity table (bayonet table ). The value of this field is saved to the bayonet range {, 02, 03}

What should I do if I need to filter the scores in the middle of an SQL string field? The following describes how to filter records of the central score of an SQL string field for your reference. For example, there is a KKBH (bayonet number) field, which is a dictionary field (corresponding to the number field of another entity table (bayonet table ). The value of this field is saved to the bayonet range {, 02, 03}

What should I do if I need to filter the scores in the middle of an SQL string field? The following describes how to filter records of the central score of an SQL string field for your reference.

For example, there is a KKBH (bayonet number) field, which is a dictionary field (corresponding to the number field of another entity table (bayonet table ). The value of this field is saved to the bayonet range {, 02, 03}

Originally, it was implemented through or, which requires dynamic generation of SQL statements.

Then I came up with a method to search for SQL strings using charindex. Make all the ID of the bayonet to be queried into a string similar to '01 @ 02. During SQL query, use charindex to filter the records of KKBH in the SQL string to be queried.

The use of or is similar to that of charindex in MSSQL.

Specific implementation:

User Interface query requirement: You may search for records with N ports (N value range {1, number of all ports }). There are three methods to design this UI:

1. Select one or more listboxes. When the user interface is running, the bayonet dictionary table is loaded into the listbox information.

2. Two listboxes: select on the left, select on the right, and add and delete buttons in the middle. When the user interface is running, the folder dictionary table is loaded into the listbox on the left.

3. Multiple checkboxes. You can directly create an infinite dictionary table during the interface design stage. There are just a few bayonet entries, just a few checkboxes. Or, when the program is running, draw a dynamic checkbox Based on the dictionary table.

The advantages and disadvantages of the UI are not discussed here. I select the third method for dynamic rendering.

In the query phase, the SQL string to be selected is generated based on the selected bayonet: "01 @ 02"

And return this condition to the backend query service program.

In the background query service, as long as the SQL string to be queried is passed into the SQL statement (SQL segment): charindex (bayonet number, @ string to be queried) as the parameter ). Of course, you can also manually generate an SQL statement to pass in "charindex (card port number, '" + query string + "')".

,

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.