简体   繁体   English

MySql 更新查询中的反斜杠不起作用

[英]Backslashes in MySql update query not working

Running the following query in MySql workbench as \ is an escape character.在 MySql 工作台中运行以下查询,因为 \ 是转义字符。

UPDATE midshared.SETUP
SET DATAVALUE = 'C:\Documents and Settings\ADMINISTRATOR\Desktop\'
WHERE CODE = 'SAGEPATH'

manually changing to this does work.手动更改为此确实有效。

UPDATE midshared.SETUP
SET DATAVALUE = 'C:\\Documents and Settings\\ADMINISTRATOR\\Desktop\\'
WHERE CODE = 'SAGEPATH'

However trying these methods that I've found on Stack Overflow don't work either -但是,尝试我在 Stack Overflow 上找到的这些方法也不起作用 -

UPDATE midshared.SETUP
SET DATAVALUE = REPLACE('C:\Settings\ADMINISTRATOR\Desktop\','\','\\')
WHERE CODE = 'SAGEPATH'

or或者

UPDATE midshared.SETUP
SET DATAVALUE = QUOTE('C:\Documents and Settings\ADMINISTRATOR\Desktop\')
WHERE CODE = 'SAGEPATH'

Can anyone point me in the right direction to fix it please?任何人都可以指出正确的方向来修复它吗? Thanks A谢谢

I tried the queries listed above我尝试了上面列出的查询

You can use double quotes safely and escape slashes as follows:您可以安全地使用双引号并转义斜杠,如下所示:

UPDATE midshared.SETUP
SET DATAVALUE = "'C:\\Documents and Settings\\ADMINISTRATOR\\Desktop\\'"
WHERE CODE_ = 'SAGEPATH'

Check the demo here .此处查看演示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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