如何获得受影响的行数,而来自bash的执行MySQL查询? [英] How to get number of rows affected, while executing mysql query from bash?
本文介绍了如何获得受影响的行数,而来自bash的执行MySQL查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在我知道有一个如何从bash中执行的MySQL查询\\命令:
Now I know how one can execute mysql queries \ commands from bash :
mysql -u[user] -p[pass] -e "[mysql commands]"
或
mysql -u[user] -p[pass] `<<`QUERY_INPUT
[mysql commands]
QUERY_INPUT
我的问题是:如何可以捕获多少行,其中受影响的查询?
我试图做:
My question is : How can I capture how many rows where affected by the query? I tried doing:
variable='`mysql -u[user] -p[pass] -e "[mysql commands]"`'
它确实执行命令,但它不返回受影响的行的数量。
It does execute the command but it does not return the number of affected rows.
感谢
推荐答案
将
SELECT ROW_COUNT();
在批处理的最后一条语句,并解析输出
as the last statement in your batch and parse the output
这篇关于如何获得受影响的行数,而来自bash的执行MySQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文