我在PHP中有一个MySQL查询,当变量是一个数值时效果很好但是当变量包含字母数字时,它会抛出一个"未知列' CC11'在' where子句'"我试图将%S包装在引号中,但我似乎无法正确格式化它?
$query_WADAHTG_TechQual = sprintf("SELECT QualID, Skill FROM HTG_TechQual WHERE EmpNumber = %s", GetSQLValueString($ParamID_WADAHTG_TechQual, "-1"));
答案 0 :(得分:1)
试试这个
$query_WADAHTG_TechQual = sprintf("SELECT QualID, Skill FROM HTG_TechQual WHERE EmpNumber = '%s'", GetSQLValueString($ParamID_WADAHTG_TechQual, "-1"));
在SQL中,字符串必须在'