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
Release: 2024-11-16 01:27:03
Original
711 people have browsed it

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;
Copy after login

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)
Copy after login

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;
Copy after login

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

id  name
1   pete
2   john
3   mike
Copy after login

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

mysql -sN ...
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template