Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
626 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...