Query returns far too many rows: accidental Cartesian product (missing JOIN condition)
Two tables were joined without a condition, so every row of one pairs with every row of the other.
Cartesian productaccidental cross joincross join missing ON clausequery returns millions of rows after joinmissing join condition duplicates rows Meaning
A missing ON, a comma join with the WHERE condition forgotten, or a condition that always matches multiplies rows (1000 x 1000 = 1,000,000). Always join with explicit ON, check row counts with COUNT(*) and review the execution plan for "nested loop" without a predicate.
Common causes
- Comma join
FROM a, bwithout a WHERE link - Missing or wrong ON condition
- Join on a non-unique column
- Using CROSS JOIN by mistake
- Join condition on the wrong alias
⚡ Quick fix
- Use explicit
JOIN ... ONwith the key columns - Compare
COUNT(*)before and after the join - Inspect the plan for a Cartesian/cross join
Detailed fix by platform
SQL
SELECT o.id, c.name FROM orders o JOIN customers c ON c.id = o.customer_id;
How to diagnose
- ON — Present?
- Row count — Exploded?
- Plan — Cartesian?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in SQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026