mahmood
mahmood

Reputation: 24705

Getting only the output of query without table shape

I use a query command from bash which returns a number. However, it is printed as a table.

$ mysql -u muser -p$PASS mm -e "SELECT.....;"
mysql: [Warning] Using a password on the command line interface  can be insecure.
+----------------------------+
| COUNT(DISTINCT ula.userid) |
+----------------------------+
|                         29 |
+----------------------------+

I just want to get 29 and append that to a file with >> file.txt. How can I do that in mysql?

Upvotes: 1

Views: 171

Answers (1)

fancyPants
fancyPants

Reputation: 51868

Use skip-column-names and batch-mode with -N and -B respectively:

mysql -u muser -p$PASS mm -NBe "SELECT.....;" >> file.txt

Upvotes: 2

Related Questions