MySQL 5.5 Case语法不正确

时间:2015-09-17 04:25:57

标签: php mysql syntax

嘿,我无法让这个案例陈述起作用,有人会介意说法语的错误是什么。

SELECT standards.standard_id, standards.title, standards.level,standards.credits, SUM(standards.credits), standards.assessment 

CASE  WHEN standards.assessment = 1 THEN 'External' ELSE 'Internal' END CASE
FROM standards JOIN courses_standards ON standards.standard_id = courses_standards.standard_id 
WHERE courses_standards.course_id = 1

确切的错误是:

  

1064 - 您的SQL语法出错;查看与您的MySQL服务器版本对应的手册,以便在'CASE WHEN standards.assessment = 1 THEN''外部'ELSE'内部'END CASE FR'第3行附近使用正确的语法

2 个答案:

答案 0 :(得分:1)

您错过了standards.assessmentCASE之间的逗号

答案 1 :(得分:0)

如果您要结束案例,则会出现语法错误。您需要在结束案件时提供别名。

SELECT standards.standard_id, standards.title, standards.level,standards.credits, SUM(    standards.credits), standards.assessment, 

CASE  WHEN standards.assessment = 1 THEN 'External' ELSE 'Internal' END assessment
FROM standards JOIN courses_standards ON standards.standard_id = courses_standards.    standard_id 
WHERE courses_standards.course_id = 1