Home >Database >Mysql Tutorial >How to suppress column headers when executing a single SQL statement in a batch using `mysql` command-line?
When executing multiple SQL statements in batch using the mysql command-line binary, you may encounter situations where you want to suppress the column headers for a particular SELECT statement. Here's how to achieve this:
Invoke mysql with the -N option (or its alias --skip-column-names):
mysql -N ...
For example:
mysql -N use testdb mysql -N select * from names;
This will suppress the column headers for the SELECT statement, resulting in output that only displays the selected records:
+------+-------+ | 1 | pete | | 2 | john | | 3 | mike | +------+-------+
To further enhance the presentation, you can use the -s (--silent) option to remove the grid (vertical and horizontal lines) around the results, separating columns with a TAB character:
mysql -s ... use testdb select * from names;
Output:
id name 1 pete 2 john 3 mike
Combining both -s and -N will produce data with no headers and no grid:
mysql -sN ...
The above is the detailed content of How to suppress column headers when executing a single SQL statement in a batch using `mysql` command-line?. For more information, please follow other related articles on the PHP Chinese website!