Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
629 views
in Technique[技术] by (71.8m points)

mysql - Get the sql query result without the table format

Like --disable-column-names option, do we have an option to get the sql query without the table format?

example:

mysql -u username -ppassword --disable-column-names --execute "select name from test"

results below:

-----
| A |
| B |
| C |
| D |
-----

IS it possible to get the query result using some sql program option modifiers as below, [ without the table format ]

A
B
C
D
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Add -B option to mysql.

mysql -B -u username -ppassword 
      --disable-column-names 
      --execute "select name from mydb.test"

-B, --batch : Print results in nontabular output format.

--execute : Execute the statement and quit.

HTH

Edit: Thanks to @ joescii, -B, which is short for --batch, also enables the --silent switch.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...