1690 🐬 MySQL

MySQL ERROR 1690 (22003): BIGINT UNSIGNED value is out of range

Arithmetic on UNSIGNED columns produced a negative result.

Seen on: MySQL

Meaning

UNSIGNED - UNSIGNED is unsigned in MySQL, so 3 - 5 overflows. Stock or balance calculations hit this.

Common causes

  • Subtracting unsigned columns
  • Decrementing below zero

⚡ Quick fix

  1. CAST to SIGNED before subtracting
  2. Use NO_UNSIGNED_SUBTRACTION sql_mode
  3. Guard against going below zero

Detailed fix by platform

MySQL

  1. SELECT CAST(stock AS SIGNED) - CAST(reserved AS SIGNED) AS available FROM products;

How to diagnose

  1. Expression — Which subtraction?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

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