Oracle 23.26SQLLab-verified · 2026-11-29

ORA-00920: invalid relational operator

A WHERE condition has no valid comparison operator, most often NOT used alone where <>, NOT IN or IS NOT NULL is needed.

Oracle AI Database 26ai Free 23.26.3.0.0
ORA-00920: invalid relational operator

Jump to a cause

  1. 01WHERE col NOT 'value' instead of <>
  2. 02Excluding several values with NOT and a list, without IN
  3. 03col NOT NULL without IS

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
Setuprun as lab_a
CREATE TABLE orders (id NUMBER PRIMARY KEY, status VARCHAR2(10));
INSERT INTO orders VALUES (1, 'OPEN');
INSERT INTO orders VALUES (2, 'CANCEL');
COMMIT;
OUTPUT
Table created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT id, status FROM orders WHERE status NOT 'CANCEL';
✕ ERROR
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/
Checkrun as lab_a
SELECT id, status FROM orders WHERE status = 'CANCEL';
OUTPUT
        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.

After the fixrun as lab_a
SELECT id, status FROM orders WHERE status <> 'CANCEL';
✓ SUCCESS
        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
Setuprun as lab_a
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;
OUTPUT
Table created.


1 row created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT id, status FROM orders WHERE status NOT 'CANCEL', 'HOLD';
✕ ERROR
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/
Checkrun as lab_a
SELECT id, status FROM orders WHERE status IN ('CANCEL', 'HOLD');
OUTPUT
        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.

After the fixrun as lab_a
SELECT id, status FROM orders WHERE status NOT IN ('CANCEL', 'HOLD');
✓ SUCCESS
        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
Setuprun as lab_a
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;
OUTPUT
Table created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT empno, ename FROM emp WHERE retire_date NOT NULL;
✕ ERROR
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/
Checkrun as lab_a
SELECT empno, ename FROM emp WHERE retire_date = NULL;
OUTPUT
no rows selected

Note 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.

After the fixrun as lab_a
SELECT empno, ename FROM emp WHERE retire_date IS NOT NULL;
✓ SUCCESS
     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