SQLite Forum

useless constant term lead to incorrect output
Login
Hello everyone,

Take this for example:

```SQL
CREATE TABLE t0(c0 PRIMARY KEY);
INSERT INTO t0(c0) VALUES (0);

SELECT * FROM t0 WHERE (c0 NOT NULL) OR (c0 == NULL);
```

The expected output is 0, and yes, the output is exactly 0.

But when adding a constant term "AND 1" to the term "c0 NOT NULL", the SQLite will get incorrect output:

```SQL
SELECT * FROM t0 WHERE ((c0 NOT NULL) AND 1) OR (c0 == NULL);
```

Nothing will be printed.

I wonder whether it is a bug.

Looking forward to your early reply :)