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

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...