Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-29 · container image gvenzl/oracle-free:23-slim
A condition such as status = 'OPEN' needs a comparison operator between the column and the value: =, <>, IN, IS NULL and so on. ORA-00920 means Oracle found something else there. The * in SQL*Plus marks the word it could not use as an operator.
In the three cases below the culprit is NOT on its own. NOT negates a condition, but it is not a comparison operator itself.
01WHERE col NOT 'value' instead of <>
WHERE status NOT 'CANCEL' reads like English, but NOT cannot compare two values. The * points at NOT.
Setup
CREATE TABLE orders (id NUMBER PRIMARY KEY, status VARCHAR2(10));
INSERT INTO orders VALUES (1, 'OPEN');
INSERT INTO orders VALUES (2, 'CANCEL');
COMMIT;Table created.
1 row created.
1 row created.
Commit complete.SELECT id, status FROM orders WHERE status NOT 'CANCEL';SELECT id, status FROM orders WHERE status NOT 'CANCEL'
*
ERROR at line 1:
ORA-00920: invalid relational operator
Help: https://docs.oracle.com/error-help/db/ora-00920/SELECT id, status FROM orders WHERE status = 'CANCEL'; ID STATUS
---------- ------------------------------
2 CANCEL
1 row selected.The table has one CANCEL order (id 2). Use <> (or !=): WHERE status <> 'CANCEL' returns the other order, id 1.
SELECT id, status FROM orders WHERE status <> 'CANCEL'; ID STATUS
---------- ------------------------------
1 OPEN
1 row selected.02Excluding several values with NOT and a list, without IN
WHERE status NOT 'CANCEL', 'HOLD' tries to exclude two values but has no IN and no parentheses. Oracle stops at NOT again.
Setup
CREATE TABLE orders (id NUMBER PRIMARY KEY, status VARCHAR2(10));
INSERT INTO orders VALUES (1, 'OPEN');
INSERT INTO orders VALUES (2, 'CANCEL');
INSERT INTO orders VALUES (3, 'HOLD');
COMMIT;Table created.
1 row created.
1 row created.
1 row created.
Commit complete.SELECT id, status FROM orders WHERE status NOT 'CANCEL', 'HOLD';SELECT id, status FROM orders WHERE status NOT 'CANCEL', 'HOLD'
*
ERROR at line 1:
ORA-00920: invalid relational operator
Help: https://docs.oracle.com/error-help/db/ora-00920/SELECT id, status FROM orders WHERE status IN ('CANCEL', 'HOLD'); ID STATUS
---------- ------------------------------
2 CANCEL
3 HOLD
2 rows selected.IN ('CANCEL', 'HOLD') finds orders 2 and 3. Write the negation as NOT IN ('CANCEL', 'HOLD'): only order 1 (OPEN) remains.
SELECT id, status FROM orders WHERE status NOT IN ('CANCEL', 'HOLD'); ID STATUS
---------- ------------------------------
1 OPEN
1 row selected.03col NOT NULL without IS
NOT NULL is how you declare a column in CREATE TABLE, so it is easy to write WHERE retire_date NOT NULL in a query too. In a condition it must be IS NOT NULL.
Setup
CREATE TABLE emp (empno NUMBER PRIMARY KEY, ename VARCHAR2(20), retire_date DATE);
INSERT INTO emp VALUES (7369, 'SMITH', NULL);
INSERT INTO emp VALUES (7499, 'ALLEN', DATE '2026-06-30');
COMMIT;Table created.
1 row created.
1 row created.
Commit complete.SELECT empno, ename FROM emp WHERE retire_date NOT NULL;SELECT empno, ename FROM emp WHERE retire_date NOT NULL
*
ERROR at line 1:
ORA-00920: invalid relational operator
Help: https://docs.oracle.com/error-help/db/ora-00920/SELECT empno, ename FROM emp WHERE retire_date = NULL;no rows selectedNote that WHERE retire_date = NULL gives no error but returns no rows selected: comparing with NULL using = is never true. Use IS NOT NULL: ALLEN, who has a retire date, is returned.
SELECT empno, ename FROM emp WHERE retire_date IS NOT NULL; EMPNO ENAME
---------- --------------------
7499 ALLEN
1 row selected.FAQ
What does ORA-00920 invalid relational operator mean?
A condition in WHERE (or ON, HAVING) has no valid operator between the column and the value. Check the word at the * position, often a lone NOT.
How do I write not equal in Oracle?
Use <> or !=: WHERE status <> 'CANCEL'. NOT 'CANCEL' gives ORA-00920.
Why does WHERE col NOT NULL fail?
In a condition you need IS: WHERE col IS NOT NULL. NOT NULL without IS is only for column definitions.
Why does WHERE col = NULL return no rows?
Comparing with NULL using = is never true, so no rows are returned and there is no error. Use IS NULL or IS NOT NULL.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0