代码之家  ›  专栏  ›  技术社区  ›  Saurabh

目标c中的逃逸百分比

  •  11
  • Saurabh  · 技术社区  · 14 年前

    我想做一个sql语句-

    sqlStatement = [NSString stringWithFormat:@"SELECT * FROM movies where title like '%%@%'",searchKeyword];
    

    但是sqlStatement正在变得-

    “从标题为“%@”的电影中选择*”

    我想成功

    “从标题为“%searchKeyword%”的电影中选择*”

    如何转义“%”字符?

    谢谢

    1 回复  |  直到 14 年前
        1
  •  23
  •   Acibi    14 年前

    尝试:

    sqlStatement = [NSString stringWithFormat:@"SELECT * FROM movies where title like '%%%@%%'",searchKeyword];
    

    “%%”是打印“%”字符的方式。