How to get the number of rows affected when executing a MySQL query from bash?

I know how to execute MySQL queries / commands from bash:

mysql -u[user] -p[pass] -e "[mysql commands]" 

or

 mysql -u[user] -p[pass] `<<`QUERY_INPUT [mysql commands] QUERY_INPUT 

How can I determine how many rows affected the query?
I tried:

 variable='`mysql -u[user] -p[pass] -e "[mysql commands]"`' 

Executes a command, but does not return the number of rows affected.

+42
bash mysql
Jul 05 '09 at 11:11
source share
3 answers

Placed

 SELECT ROW_COUNT(); 

as the last statement in your party and analyze the conclusion

+73
Jul 05 '09 at 11:26
source share

Perhaps I answered the question, looked at the options, and apparently used "-v -v -v" because the mysql command options make it more verbose and splash out how many lines are affected.

+18
Jul 05 '09 at 11:25
source share

Not an answer, but a useful addition, you can also try other MySQL information functions (including ROW_COUNT ()) to provide you with the necessary information. See MySQL link here

+3
Jan 05 2018-11-11T00:
source share



All Articles