1385
MySQLerrorqueryhigh confidence

Result consists of more than one row

Production Risk

Low — statement fails; no data changed.

What this means

A SELECT INTO or a subquery used in a scalar context returned more than one row.

Why it happens
  1. 1SELECT ... INTO var returned multiple rows
  2. 2Scalar subquery returned multiple rows (see also 1242)
  3. 3Stored routine SELECT INTO matched multiple rows
How to reproduce
trigger — this will error
trigger — this will error
SELECT name INTO @v FROM users WHERE active = 1; -- multiple active users

expected output

ERROR 1385 (HY000): Result consisted of more than one row

Fix 1

Add LIMIT 1 to restrict to a single row

Add LIMIT 1 to restrict to a single row
SELECT name INTO @v FROM users WHERE active = 1 LIMIT 1;

Why this works

Ensures only one row is returned.

Fix 2

Add a more selective WHERE clause

Why this works

Filter to the specific row you want.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 1385 ER_TOO_MANY_ROWS

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

← All MySQL errors