ORA-00905缺失关键字报错:请帮忙修正指定SQL语句错误
ORA-00905: missing keyword错误修正
原执行报错的SQL语句:
select employee_id,case first_name when first_name = "Steve" then "My name is Steve" else first_name end from hr.employees where employee_id = 150;
修正后的正确SQL语句
写法一:匹配值形式的CASE表达式
select employee_id, case first_name when 'Steve' then 'My name is Steve' else first_name end from hr.employees where employee_id = 150;
写法二:条件判断形式的CASE表达式
select employee_id, case when first_name = 'Steve' then 'My name is Steve' else first_name end from hr.employees where employee_id = 150;
错误原因
- 使用
case first_name when语法时,when后应直接跟匹配值,不能写first_name = "Steve"这类条件表达式 - Oracle中字符串常量必须用单引号包裹,双引号仅用于标识符(比如特殊命名的列名、表名)
内容的提问来源于stack exchange,提问作者Saketh Patchava
相关产品推荐
相关产品推荐

