简体   繁体   中英

Update and Replace database in MySQL with special character '

I have to change s-Gravenland into 's-Gravenland in my database

I use find and replace,

UPDATE Voornamen_2 SET Buurt = REPLACE(Buurt, 's-Gravenland', ''s-Gravenland');

This doesn't work obviously, how do I insert the extra ' ?

Use double single quotes to represent a single quote in a string:

UPDATE Voornamen_2
    SET Buurt = REPLACE(Buurt, 's-Gravenland', '''s-Gravenland');

Use an extra single quote char to accept it as part of data.

UPDATE Voornamen_2 
   SET Buurt = REPLACE( Buurt, 's-Gravenland', '''s-Gravenland' );

Or, you can also escape it to include with the data.

UPDATE Voornamen_2 
   SET Buurt = REPLACE( Buurt, 's-Gravenland', '\'s-Gravenland' );

Below query should work:

UPDATE Voornamen_2 
SET Buurt = REPLACE(Buurt, "s-Gravenland", "'s-Gravenland");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM