How to split strings in SQL statements for substitution

Source: Internet
Author: User

To meet a requirement like this, modify the parent folder name to update all the child node names.

The rule is to leave the child node pressed-the last element after the split is unchanged, and the preceding string is updated to the parent node name.

Such as:

If I modify the parent node "Southeast Network-west Coast commentary test", "Southeast Network Test", then the following node should have such a result:

The SQL statement that was originally processed:

Update websiteb set websitename=websitename where [email protected]

Obviously not enough, with stored procedures, involving cursor traversal, but also to check again to the temporary table, performance and design are not satisfied.

If it is found in the code to deal with, but also need to produce multiple execution statements for the results, it is not reasonable.

Therefore, the SQL function is intended to be used to process the value to be updated on the original SQL statement:

The SQL statement for the function is posted below:

Here is the main introduction of the next Revese (') function, SQL has a indexof function, but there is no lastindexof function.

If you want to implement a similar lastindexof function, we can first sort the string upside down and get the indexof value.

"1234," –> ', 4321 '

Indexof=1

Lastindexof=len (1234,) -1=4

The Revese () function is the ability to implement this inverted string.

With this little skill, the above needs can be solved more gracefully.

How to split strings in SQL statements for substitution

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.