What causes "subquery returns more than 1 row" in sql?

Example:

UPDATE users SET name = (SELECT name FROM otherUsers WHERE id = 1) WHERE id = 2;
This error message appears when a subquery returns more than one row where only one row is expected.

Solution:

-- Use LIMIT or a specific condition to ensure the subquery returns only one row
UPDATE users SET name = (SELECT name FROM otherUsers WHERE id = 1 LIMIT 1) WHERE id = 2;

Beginner's Guide to SQL