我已将我的数据库从MSQL转换为MySQL,我收到以下错误。
错误消息:您的SQL语法出错;查看与MySQL服务器版本对应的手册,以便在'VARCHAR(500)附近使用正确的语法=在第22行使用'男'AND Responses.res_void = 0'
我无法解决它看起来对我有效的问题?这里有没有MySQL吗?
SELECT
Responses.res_col AS answer
,Responses.res_created AS dateCreated
,Responses.res_notes AS note
,Responses.question_id AS questionID
,Responses.res_id AS responseID
,Responses.student_id AS studentID
,Responses.res_answer AS subQuestion
,Responses.survey_id AS surveyID
,Responses.res_void AS void
,Student.res_answer AS filter
FROM
Responses, Responses AS Student
WHERE
Responses.student_id = Student.student_id
AND
Responses.survey_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.surveyID#">
AND
Student.survey_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.surveyID#">
AND
Responses.question_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.questionID#"> AND
CAST(Student.res_answer AS VARCHAR(500)) = '#arguments.filter#'
AND Responses.res_void = <cfqueryparam cfsqltype="cf_sql_bit" value="#arguments.void#">
答案 0 :(得分:3)
您无法转换为VARCHAR()
类型。您可以投射到的唯一文字类型是CHAR(n)
:
CAST(Student.res_answer AS CHAR(500)) = '#arguments.filter#'
从mysql doc开始,结果的类型可以是以下值之一:
BINARY[(N)]
CHAR[(N)]
DATE
DATETIME
DECIMAL[(M[,D])]
SIGNED [INTEGER]
TIME
UNSIGNED [INTEGER]