开发者

mysql - replace ' with single quote in a field

开发者 https://www.devze.com 2023-01-26 16:20 出处:网络
I\'m not exactly sure what happened because I migrated from One server to another of the same spec and SQL...

I'm not exactly sure what happened because I migrated from One server to another of the same spec and SQL...

Still in comments and titles the new database shows the characters ' instead of '

and I was wondering if I could ask for help in either replacing 开发者_开发百科' with '

or if it was simpler just deleting '

Thanks so much...

Steff


You could use MySQL's REPLACE method (look here):

UPDATE
Changed the statement to reflect the OP's naming:

UPDATE database1.vb_ppgal_albums
   SET pp_photos = REPLACE(pp_photos, ''', '\'') 

Good luck.


The following is the coding that I use to update double-quote in MySQL. I use the REPLACE function. The first parameter is the field_name that I want to have searched, the second is the escaping of the double quote (\") as the search string, followed by escaping of the escape character (\) followed by the double quote, which will insert into the field name (\"). In the table I will now have a measurement of '1/2\"' instead of '1/2"', which was my goal. I hope this helps. (PS, the Where clause is for show, you may not need it.)

UPDATE `table_name` 
SET 
`field_name` = REPLACE(`field_name`, '\"', '\\"')
WHERE `Id` > 125
0

精彩评论

暂无评论...
验证码 换一张
取 消