【问题标题】:UPDATE Adressen SET `Straße`=REPLACE(`Straße`,'\','');" - How to escape \ in mysql?UPDATE Adressen SET `Straße`=REPLACE(`Straße`,'\','');" - 如何在 mysql 中转义 \?
【发布时间】:2020-03-24 09:04:55
【问题描述】:

我正在使用https://www.mysqltutorial.org/mysql-string-replace-function.aspx,但我无法替换:\

我在 MacOS 上使用 DBeaver。

它与其他字母一起使用:

UPDATE products 
SET 
    productDescription = REPLACE(productDescription,
        'abuot',
        'about');

但这不起作用:

UPDATE products 
SET 
    productDescription = REPLACE(productDescription,
        '\',
        '');

【问题讨论】:

    标签: mysql node.js macos dbeaver


    【解决方案1】:

    您必须使用双反斜杠 (\\) 转义反斜杠 (\):

    UPDATE products SET productDescription = REPLACE(productDescription, '\\', '');
    

    demo on dbfiddle.uk

    您可以在the MySQL documentation 上找到包含所有特殊字符的列表(表 9.1 特殊字符转义序列)。

    【讨论】:

    • 非常感谢。我不知道,为什么我不让它工作。我相信你的回答是对的,但不知怎的,我一定是做错了什么。
    • 啊,谢谢!是的,它的工作原理。我需要逃避更多 - 因为我用 nodejs 调用它:D 我需要写 4 个 \\\\.谢谢!
    猜你喜欢
    • 1970-01-01
    • 2015-11-02
    • 2015-01-05
    • 1970-01-01
    • 2012-12-09
    • 1970-01-01
    • 1970-01-01
    • 2017-04-30
    • 1970-01-01
    相关资源
    最近更新 更多