Home >Database >Mysql Tutorial >【MySQL】命令行执行sql,去除字段名

【MySQL】命令行执行sql,去除字段名

WBOY
WBOYOriginal
2016-06-07 15:17:441233browse

mysql的-e选项可以让我们在命令行下执行sql: /bin/mysql -h localhost -u {user_name} -p{password} -P 3308 {db_name} -e select id from {table_name} where uid=1; ------- | id | ------- | 10162 | | 10151 | | 10152 | ------- 发现上面带了字段名id,

mysql的-e选项可以让我们在命令行下执行sql:

/bin/mysql -h localhost -u {user_name} -p{password} -P 3308 {db_name} -e "select id from {table_name} where uid=1;"
+-------+
| id    |
+-------+
| 10162 |
| 10151 |
| 10152 |
+-------+


发现上面带了字段名id,去掉字段名可以用-N选项(--skip-column-names(-N)):

/bin/mysql -h localhost -u {user_name} -p{password} -P 3308 {db_name} -Ne "select id from {table_name} where uid=1;"
+-------+
| 10162 |
| 10151 |
| 10152 |
+-------+


参考:http://blog.sina.com.cn/s/blog_71fbce730100obnq.html


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn