执行
update test2
set name=
(select concat(firstName," ",lastName)
from test1 where test2.test1_id=test1.id)
报出【mysql 1242 subquery returns more than 1 row】的错误
通过字面意思明白了 查询返回的结果有重复的
使用distinct函数过滤 问题解决
update test2
set name=
(select distinct(concat(firstName," ",lastName))
from test1 where test2.test1_id=test1.id)
update test2
set name=
(select concat(firstName," ",lastName)
from test1 where test2.test1_id=test1.id)
报出【mysql 1242 subquery returns more than 1 row】的错误
通过字面意思明白了 查询返回的结果有重复的
使用distinct函数过滤 问题解决
update test2
set name=
(select distinct(concat(firstName," ",lastName))
from test1 where test2.test1_id=test1.id)
本文介绍了一种在MySQL中更新数据表时遇到的错误【mysql1242subqueryreturnsmorethan1row】及其解决方案。当子查询返回多行数据而非单一结果时,此错误将被触发。文章详细说明了如何通过添加distinct关键字来过滤重复项,从而解决该问题。
3967

被折叠的 条评论
为什么被折叠?



