PostgreSQL error code
PostgreSQL error 42804
42804 is the SQLSTATE PostgreSQL reports for datatype mismatch, in class 42, Syntax Error or Access Rule Violation.
| SQLSTATE | 42804 |
|---|---|
| Condition name | datatype_mismatch |
| Class | 42 — Syntax Error or Access Rule Violation |
Reproduce it, then fix it
WHERE needs a boolean. MySQL and SQLite treat a non-zero number as true, but PostgreSQL makes you write the comparison. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
SELECT name FROM products WHERE stock_quantity;
SELECT name FROM products WHERE stock_quantity > 0;