UPDATE with no subquery throws error: Subquery returns more than 1 row

血红的双手。 提交于 2019-12-20 03:20:59

问题


Can somebody explain to me this... :) (using MySQL 5.6.13)

UPDATE offer SET cosid=1 WHERE id=40;
Query OK, 1 row affected (0.07 sec)
Rows matched: 1  Changed: 1  Warnings: 0

UPDATE offer SET cosid=4 WHERE id=40;
ERROR 1242 (21000): Subquery returns more than 1 row

UPDATE offer SET cosid=5 WHERE id=40;
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Every valid index is accepted except of four :(

This is offer table:

CREATE TABLE offer (
  id               bigint(20) NOT NULL AUTO_INCREMENT, 
  authorid         bigint(20) NOT NULL, 
  offered_designid bigint(20) NOT NULL, 
  cdid             bigint(20), 
  cosid            bigint(20) NOT NULL, 
  PRIMARY KEY (id), 
  UNIQUE INDEX (id)) ENGINE=InnoDB;

Any suggestion what might be wrong?

EDITED: This is current cos table:

SELECT * FROM cos;
+----+-------------+
| id | offer_state |
+----+-------------+
|  1 | active      |
|  5 | cancelled   |
|  3 | inactive    |
|  4 | realized    |
|  2 | waiting     |
+----+-------------+

5 rows in set (0.00 sec)


回答1:


As ypercube has stated in the comments, and you have confirmed, triggers are the culprit here!



来源:https://stackoverflow.com/questions/18708376/update-with-no-subquery-throws-error-subquery-returns-more-than-1-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!