Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I suppress column header output for a single SQL statement?

People also ask

How do I remove a column header in SQL?

When you use the sp_send_dbmail stored procedure to email the results of a query, the column headers are included by default. You can include or exclude the column headers with the @query_result_header argument. To remove the column headers, use @query_result_header = 0 .

How do I ignore a column name in SQL?

How to do this in SQL Server? Simple, don't use select *. You should avoid that anyway and ONLY select the columns you want. It doesn't matter that you have 100 columns, if you don't want one of them returned you simply can't use select *.

How do I set column headers in SQL?

To change a column heading to two or more words, enclose the new heading in single or double quotation marks when you enter the COLUMN command. To display a column heading on more than one line, use a vertical bar (|) where you want to begin a new line.

How do I select a header in SQL?

In SQL Server, you can select COLUMN_NAME from INFORMATION_SCHEMA. COLUMNS .


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 ...

You can fake it like this:

-- with column headings 
select column1, column2 from some_table;

-- without column headings
select column1 as '', column2 as '' from some_table;