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 只有一个值;

热门帖子
- 12025-12-01浏览数:182759
- 22023-05-09浏览数:25044
- 42023-09-25浏览数:18519
- 52020-05-11浏览数:17526