用字符'更新mysql'

时间:2012-06-23 15:50:14

标签: mysql

在我的价值中,我有角色'我收到一个错误。

我该如何解决?

    UPDATE products
SET description = CASE
    WHEN id <= 350 THEN 'Sample description with ' character'
    ELSE 'sample description 2'
END

3 个答案:

答案 0 :(得分:1)

在SQL中转义字符的常用方法是\ so

    UPDATE products
SET description = CASE
    WHEN id <= 350 THEN 'Sample description with \' character'
    ELSE 'sample description 2'

如果你想知道如何把\放在那里,你只需加倍,即\\

答案 1 :(得分:0)

报价加倍:

UPDATE products
SET description = CASE
WHEN id <= 350 THEN 'Sample description with '' character'
ELSE 'sample description 2'
END

答案 2 :(得分:0)

phpMyAdmin 将报价加倍。你可以这样做:

UPDATE `products`
SET `description` = CASE
    WHEN `id` <= 350 THEN 'Sample description with '' character'
    ELSE 'sample description 2'
END