The replace replacement string in MySQL returns the result empty or 0

Source: Internet
Author: User

Why execute a MySQL statement, replace the character with the Replace function, but return a result of 0? This SQL statement is written like this:

The code is as follows Copy Code

UPDATE V9_news_data Set Content=replace (' content ', ' <p>[NextPage]</p> ', ' [Page] ')
and pagin=2 where INSTR (' content ', ' <p>[NextPage]</p> ') > 0;

When the result is done, the desired replacement effect is not implemented and the result is 0. What's going on here.

Then restore the database, remove and pagin=2 this sentence and then try OK, can't the Replace function updata multiple fields at the same time in the UPDATE statement? Then it has to be distributed.

The MySQL repalce function is written in the correct notation:

The code is as follows Copy Code

UPDATE V9_news_data Set Content=replace (' content ', ' <p>[NextPage]</p> ', ' [Page] ') where INSTR (' content ', ' <p>[NextPage]</p> ') > 0;

It's best to replace only one field at a time, I don't know if it's the reason for the update, or the content is too long the field character,

The code is as follows Copy Code

INSTR (' content ', ' <p>[NextPage]</p> ') > 0

The following sentence InStr function to determine whether there is this string, it is necessary to add in order to avoid errors.

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.