Mysql语句中动态变量包含引号


    Francesca'  S控股为变量值,中间含有单引号  。MQL把变量中的 '读取了没有当做纯文本


SELECT
    id AS id,
    brand_name AS brandName,
    keywords AS keywords,
    description AS description
 FROM
    brand AS Brand
WHERE
    brand_name LIKE '%Francesca ' S控股 % '
ORDER BY id ASC

错误如下


[SQL]SELECT
    id AS id,
    brand_name AS brandName,
    keywords AS keywords,
    description AS description
FROM
    brand AS Brand
WHERE
    brand_name LIKE '%Francesca'  S控股 % ' ORDER BY id ASC

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S控股 % '
 ORDER BY id ASC' at line 9



更新后在引号前加入\,'变成了\' 不再报错,把整个参数当成了纯文本

SELECT
    id AS id,
    brand_name AS brandName,
    keywords AS keywords,
    description AS description
FROM
    brand AS Brand
WHERE

    brand_name LIKE '%Francesca\'  S控股 % ' ORDER BY id ASC


你可能感兴趣的:(mysql)