java - MYSQL5.6 ROW_COUNT()返回不一致
高洛峰
高洛峰 2017-04-18 09:05:55
0
1
356

表t_test中已存在id = 97并且num = 2的记录

重复执行以下SQL:

UPDATE t_test SET num = 2 WHERE id = 97;
select ROW_COUNT();

在navicat for mysql或者mysql workbench中,ROW_COUNT()=0,但是在java程序(dbutils框架)中总是返回1,有没有大神解释一下?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
黄舟

The normal code is to return 0, because the meaning of this value is the number of affected rows. Since the original value here is already 2, the result of the number of affected rows is 0, which is correct.
I don’t know much about this framework. I guess the reason is as follows:
Because the framework considers that the result here is generally used as a sign to judge whether the operation is successful or not. If it keeps returning 0, it will enter the wrong logic, so most frameworks will be re-modified. this value.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!