嘿,我不能让这个case语句工作,有人介意告诉我语法有什么问题吗。

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,然后在第3行“External”ELSE“Internal”END CASE FR“附近使用的正确语法

最佳答案

你结束案子的方式有语法错误。您需要在结束案例时提供别名。

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

10-08 14:18