1288
MySQLerrorqueryhigh confidence

The target table for UPDATE is not updatable

Production Risk

Low — statement fails; no data changed.

What this means

An UPDATE or DELETE was issued against a view that is not updatable because it contains aggregation, DISTINCT, GROUP BY, UNION, or other constructs that prevent row-level mapping back to the base table.

Why it happens
  1. 1Updating a view defined with GROUP BY, DISTINCT, aggregate functions, or UNION
  2. 2View joins multiple tables and the row cannot be uniquely mapped to one base table row
How to reproduce
trigger — this will error
trigger — this will error
UPDATE (SELECT MAX(salary) AS ms FROM employees) tmp SET ms = 100000;

expected output

ERROR 1288 (HY000): The target table tmp of the UPDATE is not updatable

Fix

Update the base table directly

Update the base table directly
UPDATE employees SET salary = 100000 WHERE id = 1;

Why this works

Bypass the view and operate on the underlying table.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 1288 ER_NON_UPDATABLE_TABLE

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors