Display query results without table row in mysql shell (non-letter output)

Is it possible to display query results as shown below in mysql shell?

mysql> select code, created_at from my_records; code created_at 1213307927 2013-04-26 09:52:10 8400000000 2013-04-29 23:38:48 8311000001 2013-04-29 23:38:48 3 rows in set (0.00 sec) 

instead

 mysql> select code, created_at from my_records; +------------+---------------------+ | code | created_at | +------------+---------------------+ | 1213307927 | 2013-04-26 09:52:10 | | 8400000000 | 2013-04-29 23:38:48 | | 8311000001 | 2013-04-29 23:38:48 | +------------+---------------------+ 3 rows in set (0.00 sec) 

The reason I ask, because I have a tedious task, I need to copy the output and paste it onto another tool.

+7
sql mysql
source share
5 answers

- raw, -r

For tabular output, boxing around columns allows you to distinguish one column value from another. For non-point output (for example, generated in batch mode or when the -batch or -silent option is specified), special characters are escaped at the output so that they can be easily identified. Newline, tab, NUL and backslash are written as \ n, \ t, \ 0 and \\. The -raw option disables the escaping of this character.

The following example demonstrates tabular and non-point output and using raw mode to disable shielding:

 % mysql mysql> SELECT CHAR(92); +----------+ | CHAR(92) | +----------+ | \ | +----------+ % mysql -s mysql> SELECT CHAR(92); CHAR(92) \\ % mysql -s -r mysql> SELECT CHAR(92); CHAR(92) \ 

From MySQL Docs

+15
source share

Not what you need, but it can be useful. Add \ G at the end of the query

 select code, created_at from my_records\G; 

The query result will look like this:

 *************************** 1. row *************************** code: 1213307927 created_at: 2013-04-26 09:52:10 *************************** 2. row *************************** code: 8400000000 created_at: 2013-04-29 23:38:48 
+6
source share

Single liner

 mysql -u YOURUSER -p --password=YOURPASSWORD -s -r -e "show databases;" mysql -u root -p --password=abc12345 -s -r -e "show databases;" 
+1
source share

I solved this, but using concat_ws to concatenate the results together and then add a space (first argument)

 select concat_ws (' ',ipNetFull,ipUsage,broadcast,gateway) from ipNets; 
0
source share

You need to pass the -s mysql -s .

0
source share

All Articles