GBase 8a
其他
文章

执行update报错can not update one row to multi-data问题处理

发表于2025-03-29 18:17:0065次浏览2个评论

GBase 8a 版本: 9.5.3.27.20_patch.466f776a 

1、建表和插入数据

2、问题复现:报错can not update one row to multi-data     &         Subquery return more than 1 row

 

3、原因分析

通过以下SQL可以发现,在id =2 的条件下,两表关联查询后,vlalue字段的值有2个,虽然都是 234,但是仍然是多个值赋给1个值。

gbase> select t2.id,count(t2.value) from t1,t2 where t1.id=t2.id group by 1  order by 2 desc ;
+------+-----------------+
| id   | count(t2.value) |
+------+-----------------+
|    1 |               1 |
|    2 |               2 |
+------+-----------------+
2 rows in set (Elapsed: 00:00:00.41)

4、针对这种情况规避措施

(1)、使用distinct去重后value 只有一个值;

(2)、使用limit 1,确保value 只有一个值;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论

登录后才可以发表评论
用户头像
levvel发表于 8个月前
我看好你哟!
爱笑的眼睛发表于 2个月前
学会了