Oracle Homework - SQL语句错误 - 再次

时间:2012-02-29 20:53:52

标签: sql

我不确定为什么会收到此错误,此代码非常简单。错误是:

ORA-00920:无效的关系运算符

代码是:

SELECT FIRST_NAME || ' ' || LAST_NAME AS "EMPLOYEES"
FROM F_STAFFS
WHERE LAST_NAME LIKE 'D%'
AND LAST_NAME LIKE '%a%' AND '%e%';

我正在尝试在标题为“EMPLOYEES”的列中显示名字和姓氏,其中姓氏以“D”开头,姓氏包含字母“a”和“e”。

谢谢!

2 个答案:

答案 0 :(得分:5)

SELECT FIRST_NAME || ' ' || LAST_NAME AS "EMPLOYEES"
FROM F_STAFFS
WHERE LAST_NAME LIKE 'D%'
AND LAST_NAME LIKE '%a%' AND LAST_NAME LIKE '%e%';

但这可以简化为:

SELECT FIRST_NAME || ' ' || LAST_NAME AS "EMPLOYEES"
FROM F_STAFFS
WHERE LAST_NAME LIKE 'D%a%' AND LAST_NAME LIKE '%e%';

答案 1 :(得分:0)

'%e%'不是有效的逻辑表达式。

你需要的是:

AND LAST_NAME LIKE '%a%' AND LAST_NAME LIKE '%e%';