Seaquel
PostgreSQL error code

PostgreSQL error 21000

21000 is the SQLSTATE PostgreSQL reports for cardinality violation, in class 21, Cardinality Violation.

SQLSTATE21000
Condition namecardinality_violation
Class21 — Cardinality Violation

Reproduce it, then fix it

These are the queries from the guide below. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.

SELECT name, price
FROM demo.products
WHERE id = (SELECT product_id FROM demo.order_items WHERE order_id = 3);
SELECT name, price
FROM demo.products
WHERE id IN (SELECT product_id FROM demo.order_items WHERE order_id = 3);

How to fix it

In other databases

Source: PostgreSQL documentation, Appendix A