How can I suppress column header output for a single SQL statement?
columnheader, mysql, output, suppression
Solution
Invoke mysql with the `-N` (the alias for `-N` is `--skip-column-names`) option:
mysql -N ...
use testdb;
select * from names;
+------+-------+
| 1 | pete |
| 2 | john |
| 3 | mike |
+------+-------+
3 rows in set (0.00 sec)
Credit to ErichBSchulz for pointing out the -N alias.
To remove the grid (the vertical and horizontal lines) around the results use `-s` (`--silent`). Columns are separated with a `TAB` character.
mysql -s ...
use testdb;
select * from names;
id name
1 pete
2 john
3 mike
To output the data with no headers and no grid just use both `-s` and `-N`.
mysql -sN ...
Problem
I'm executing some SQL statements in batch (using the `mysql` command-line binary). I want one of my several SELECT statements to not print the column headers, just the selected records. Is this possible?