获取不带表格式的sql查询结果 [英] Get the sql query result without the table format

查看:85
本文介绍了获取不带表格式的sql查询结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

--disable-column-names选项一样,我们是否可以选择不使用表格式的sql查询?

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

示例:

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

结果如下:

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

使用下面的某些sql程序选项修饰符可以获得查询结果,[没有表格格式]

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

A
B
C
D

推荐答案

mysql添加-B选项.

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

-B -批处理:以非表格输出格式打印结果.

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

-执行:执行该语句并退出.

--execute : Execute the statement and quit.

HTH

由于@ joescii,-B(--batch的缩写)也启用了--silent开关.

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

这篇关于获取不带表格式的sql查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆