Home >Database >Mysql Tutorial >How to Suppress Column Headers in Specific SQL Statements?

How to Suppress Column Headers in Specific SQL Statements?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-16 01:27:03713browse

How to Suppress Column Headers in Specific SQL Statements?

Suppressing Column Headers for Specific SQL Statements

When executing multiple SQL statements in batch, you may encounter the need to suppress column headers for a particular statement. This can be achieved by utilizing the -N option while invoking mysql.

The -N option, also known as --skip-column-names, disables the output of column headers for the subsequent SQL statement. For example:

mysql -N ...
use testdb;
select * from names;

This command will execute the SELECT statement without printing column headers, resulting in the following output:

+------+-------+
|    1 | pete  |
|    2 | john  |
|    3 | mike  |
+------+-------+
3 rows in set (0.00 sec)

Note: To remove the grid (vertical and horizontal lines) around the results, use the -s (or --silent) option.

Example:

mysql -s ...
use testdb;
select * from names;

This will output the data in a tabular format without the grid:

id  name
1   pete
2   john
3   mike

Tip: If you wish to suppress both column headers and the grid, simply combine the -s and -N options:

mysql -sN ...

The above is the detailed content of How to Suppress Column Headers in Specific SQL Statements?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn