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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:17:44
Original
1246 people have browsed it

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 of this Website
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template