mysql 1242 subquery returns more than 1 row

执行
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 1242 subquery returns more than 1 row)